Browse Source

Minor bug fix in HTTP::QueryString

release/0.19
Jessica James 9 years ago
parent
commit
8dccb82a3c
  1. 16
      Jupiter/HTTP_QueryString.h
  2. BIN
      Release/Jupiter.lib

16
Jupiter/HTTP_QueryString.h

@ -52,7 +52,7 @@ namespace Jupiter
HTMLFormResponse() = delete; HTMLFormResponse() = delete;
inline HTMLFormResponse(const Jupiter::ReadableString &query_string) : HTMLFormResponse(query_string.ptr(), query_string.size()) {} inline HTMLFormResponse(const Jupiter::ReadableString &query_string) : HTMLFormResponse(query_string.ptr(), query_string.size()) {}
inline HTMLFormResponse(const char *ptr, size_t str_size); inline HTMLFormResponse(const char *ptr, size_t str_size);
Jupiter::INIFile table; Jupiter::INIFile::Section table;
}; };
} }
} }
@ -132,9 +132,9 @@ inline Jupiter::HTTP::HTMLFormResponse::HTMLFormResponse(const char *ptr, size_t
} }
} }
const char *token_start = ptr;
const char *end = ptr + str_size - 2; const char *end = ptr + str_size - 2;
char *buf = str; char *buf = str;
const char *token_start = buf;
int val; int val;
Jupiter::ReferenceString key; Jupiter::ReferenceString key;
@ -164,17 +164,17 @@ inline Jupiter::HTTP::HTMLFormResponse::HTMLFormResponse(const char *ptr, size_t
else if (*ptr == '&') // End of key/value, start of key else if (*ptr == '&') // End of key/value, start of key
{ {
if (key.isNotEmpty()) // A key was already set; end of value if (key.isNotEmpty()) // A key was already set; end of value
Jupiter::HTTP::HTMLFormResponse::table.set(Jupiter::ReferenceString::empty, key, Jupiter::ReferenceString(token_start, ptr - token_start)); Jupiter::HTTP::HTMLFormResponse::table.set(key, Jupiter::ReferenceString(token_start, buf - token_start));
key.erase(); key.erase();
++buf, ++ptr; ++buf, ++ptr;
token_start = ptr; token_start = buf;
} }
else if (*ptr == '=') // End of key, start of value else if (*ptr == '=') // End of key, start of value
{ {
key.set(token_start, ptr - token_start); key.set(token_start, buf - token_start);
++buf, ++ptr; ++buf, ++ptr;
token_start = ptr; token_start = buf;
} }
else // Copy character else // Copy character
{ {
@ -186,6 +186,10 @@ inline Jupiter::HTTP::HTMLFormResponse::HTMLFormResponse(const char *ptr, size_t
// copy last 2 characters // copy last 2 characters
*buf = *ptr; *buf = *ptr;
*++buf = *++ptr; *++buf = *++ptr;
if (key.isNotEmpty()) // A key was already set; end of value
Jupiter::HTTP::HTMLFormResponse::table.set(key, Jupiter::ReferenceString(token_start, buf - token_start + 1));
Jupiter::StringType::length = buf + 1 - str; Jupiter::StringType::length = buf + 1 - str;
} }

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save