Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix parsing double % in query parameters

  • Loading branch information...
commit 142bb2589dc184709857c08c1e10570947c444e3 1 parent 470ab65
@maekitalo authored
Showing with 15 additions and 1 deletion.
  1. +6 −1 src/query_params.cpp
  2. +9 −0 test/query_params-test.cpp
View
7 src/query_params.cpp
@@ -134,10 +134,15 @@ namespace
if (_cnt == 0)
{
if (_state == state_keyesc)
+ {
+ _key += '%';
_state = state_key;
+ }
else
+ {
+ _value += '%';
_state = state_value;
- parse('%');
+ }
}
else
{
View
9 test/query_params-test.cpp
@@ -40,6 +40,7 @@ class QueryParamsTest : public cxxtools::unit::TestSuite
registerMethod("testCopy", *this, &QueryParamsTest::testCopy);
registerMethod("testParseUrl", *this, &QueryParamsTest::testParseUrl);
registerMethod("testParseUrlSpecialChar", *this, &QueryParamsTest::testParseUrlSpecialChar);
+ registerMethod("testParseDoublePercent", *this, &QueryParamsTest::testParseDoublePercent);
registerMethod("testCount", *this, &QueryParamsTest::testCount);
registerMethod("testCombine", *this, &QueryParamsTest::testCombine);
registerMethod("testIterator", *this, &QueryParamsTest::testIterator);
@@ -97,6 +98,14 @@ class QueryParamsTest : public cxxtools::unit::TestSuite
CXXTOOLS_UNIT_ASSERT_EQUALS(q["m\xa4kitalo"], "tommi ");
}
+ void testParseDoublePercent()
+ {
+ cxxtools::QueryParams q;
+ q.parse_url("%%=%%%");
+ CXXTOOLS_UNIT_ASSERT(q.has("%%"));
+ CXXTOOLS_UNIT_ASSERT_EQUALS(q["%%"], "%%%");
+ }
+
void testCount()
{
cxxtools::QueryParams q;
Please sign in to comment.
Something went wrong with that request. Please try again.