RPC console: don't crash on invalid input exception

This commit is contained in:
Wladimir J. van der Laan 2012-05-12 18:14:29 +02:00
parent c6aa86afc2
commit ae744c8b78
1 changed files with 17 additions and 10 deletions

View File

@ -55,12 +55,13 @@ void RPCExecutor::start()
void RPCExecutor::request(const QString &command)
{
// Parse shell-like command line into separate arguments
std::string strMethod;
std::vector<std::string> strParams;
try {
boost::escaped_list_separator<char> els('\\',' ','\"');
std::string strCommand = command.toStdString();
boost::tokenizer<boost::escaped_list_separator<char> > tok(strCommand, els);
std::string strMethod;
std::vector<std::string> strParams;
int n = 0;
for(boost::tokenizer<boost::escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg,++n)
{
@ -69,6 +70,12 @@ void RPCExecutor::request(const QString &command)
else
strParams.push_back(*beg);
}
}
catch(boost::escaped_list_error &e)
{
emit reply(RPCConsole::CMD_ERROR, QString("Parse error"));
return;
}
try {
std::string strPrint;