aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Chat/Chat.cpp28
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, "\"");
}
}