diff --git a/src/cmnds/cmd_tokenizer.c b/src/cmnds/cmd_tokenizer.c index 9fd883017..f3e51e1e3 100644 --- a/src/cmnds/cmd_tokenizer.c +++ b/src/cmnds/cmd_tokenizer.c @@ -153,8 +153,16 @@ void Tokenizer_TokenizeString(const char *s, int flags) { return; } + // not really needed, but nice for testing + memset(g_args, 0, sizeof(g_args)); + memset(g_argsFrom, 0, sizeof(g_argsFrom)); + strcpy(g_buffer,s); p = g_buffer; + // we need to rewrite this function and check it well with unit tests + if (*p == '"') { + goto quote; + } g_args[g_numArgs] = p; g_argsFrom[g_numArgs] = (s+(p-g_buffer)); g_numArgs++; @@ -162,7 +170,7 @@ void Tokenizer_TokenizeString(const char *s, int flags) { if(isWhiteSpace(*p)) { *p = 0; if(p[1] != 0 && isWhiteSpace(p[1])==false) { - // we need to rewrite this function + // we need to rewrite this function and check it well with unit tests if(g_bAllowQuotes && p[1] == '"') { p++; goto quote; diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index 4b3fce22d..cd48fa9ab 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -439,11 +439,14 @@ int postany(http_request_t* request, const char* str, int len) { int addlen = len; if (NULL == str) { - if (request->replylen > 0) { - send(request->fd, request->reply, request->replylen, 0); + // fd will be NULL for unit tests where HTTP packet is faked locally + if (request->fd != 0) { + if (request->replylen > 0) { + send(request->fd, request->reply, request->replylen, 0); + } + request->reply[0] = 0; + request->replylen = 0; } - request->reply[0] = 0; - request->replylen = 0; return 0; }