Merge pull request #6168 from heliclei/fix-console-upload

closed #4533:fix console upload hang issue
This commit is contained in:
minggo 2014-04-08 17:55:15 +08:00
Родитель e2252cafe3 4e1284bd45
Коммит 6208943cb1
1 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -765,6 +765,8 @@ void Console::commandTouch(int fd, const std::string& args)
}
}
static char invalid_filename_char[] = {':', '/', '\\', '?', '%', '*', '<', '>', '"', '|', '\r', '\n', '\t'};
void Console::commandUpload(int fd)
{
ssize_t n, rc;
@ -775,11 +777,20 @@ void Console::commandUpload(int fd)
{
if( (rc = recv(fd, &c, 1, 0)) ==1 )
{
*ptr++ = c;
for(char x : invalid_filename_char)
{
if(c == x)
{
const char err[] = "upload: invalid file name!\n";
send(fd, err, sizeof(err),0);
return;
}
}
if(c == ' ')
{
break;
}
*ptr++ = c;
}
else if( rc == 0 )
{
@ -875,10 +886,10 @@ bool Console::parseCommand(int fd)
}
else
{
const char err[] = "Unknown Command!\n";
sendPrompt(fd);
const char err[] = "upload: invalid args! Type 'help' for options\n";
send(fd, err, sizeof(err),0);
return false;
sendPrompt(fd);
return true;
}
}
@ -909,7 +920,7 @@ bool Console::parseCommand(int fd)
const char err[] = "Unknown command. Type 'help' for options\n";
send(fd, err, sizeof(err),0);
sendPrompt(fd);
return false;
return true;
}
auto it = _commands.find(trim(args[0]));