aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Chat/Chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
-rw-r--r--src/server/game/Chat/Chat.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index c7fbb4c9df1..91f62c1a697 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -1198,10 +1198,34 @@ 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, " ");
+ static char arg[1];
+ arg[0] = '\0';
+ return arg;
+ }
+ else
+ return strtok(args + 1, "\"");
+ }
+ else
return NULL;
- return strtok(NULL, "\"");
}
}