diff options
| author | jackpoz <giacomopoz@gmail.com> | 2014-03-29 21:07:46 +0100 | 
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2014-03-29 21:07:46 +0100 | 
| commit | 4cffd2e7079d8ad091fe3021caffd2b4ffdabd3b (patch) | |
| tree | 6d6adfcd2b525403982338f69c18681a3d362fcc | |
| parent | 0b615ec159eb5cb969bac92206d059c529642d8f (diff) | |
Core/Commands: Handle "" as empty string argument
Fixes #11548
| -rw-r--r-- | src/server/game/Chat/Chat.cpp | 28 | 
1 files changed, 25 insertions, 3 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index d90fd6f8443..59ba67f96e9 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -1180,10 +1180,32 @@ char* ChatHandler::extractQuotedArg(char* args)          return strtok(args+1, "\"");      else      { -        char* space = strtok(args, "\""); -        if (!space) +        // skip spaces +        while (*args == ' ') +        { +            args += 1; +            continue; +        } + +        // return NULL if we reached the end of the string +        if (!*args) +            return NULL; + +        // since we skipped all spaces, we expect another token now +        if (*args == '"') +        { +            // return an empty string if there are 2 "" in a row. +            // strtok doesn't handle this case +            if (*(args + 1) == '"') +            { +                strtok(args, " "); +                return ""; +            } +            else +                return strtok(args + 1, "\""); +        } +        else              return NULL; -        return strtok(NULL, "\"");      }  }  | 
