Fixed incorrect command splitting for custom actions

FossilOrigin-Name: 29c6a41585bad0bf9f506ea3ba148bb3ad3a2dca
This commit is contained in:
kostas
2015-08-22 11:04:16 +00:00
parent 8a2c6293c2
commit 1efc307718
3 changed files with 16 additions and 13 deletions

View File

@@ -517,7 +517,8 @@ QString UrlToStringNoCredentials(const QUrl& url)
void SplitCommandLine(const QString &commandLine, QString &command, QString &extraParams)
{
// Process command string
command = commandLine;
command = commandLine.trimmed();
Q_ASSERT(!command.isEmpty());
// Split command from embedded params
@@ -525,20 +526,22 @@ void SplitCommandLine(const QString &commandLine, QString &command, QString &ext
// Command ends after first space
QChar cmd_char_end = ' ';
int start = 0;
int cmd_start = 0;
int backtrack = 0;
// ...unless it is a quoted command
if(command[0]=='"')
{
cmd_char_end = '"';
start = 1;
cmd_start = 1;
backtrack = 1;
}
int cmd_end = command.indexOf(cmd_char_end, start);
int cmd_end = command.indexOf(cmd_char_end, cmd_start);
if(cmd_end > 0)
{
extraParams = command.mid(cmd_end+1);
command = command.mid(start, cmd_end-1);
command = command.mid(cmd_start, cmd_end-backtrack);
}
command = command.trimmed();