Skip to content

Commit

Permalink
Fix Url Query formatting
Browse files Browse the repository at this point in the history
fixes #12883
  • Loading branch information
Crunsher committed Oct 14, 2016
1 parent f0f0302 commit 2ef6642
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/remote/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ String Url::Format(bool print_credentials) const
// Just one (or one empty) value
if (kv.second.size() == 1) {
param += key;
param += kv.second[0].IsEmpty() ? "" : "=" + Utility::EscapeString(kv.second[0], ACQUERY_ENCODE, false);
param += kv.second[0].IsEmpty() ?
String() : "=" + Utility::EscapeString(kv.second[0], ACQUERY_ENCODE, false);
continue;
}

Expand All @@ -271,7 +272,6 @@ String Url::Format(bool print_credentials) const
temp += "&";

temp += key;

if (kv.second.size() > 1)
temp += "[]";

Expand Down Expand Up @@ -384,7 +384,7 @@ bool Url::ParseQuery(const String& query)
String key = token.SubStr(0, pHelper);
String value = Empty;

if (pHelper != token.NPos && pHelper != token.GetLength() - 1)
if (pHelper != String::NPos && pHelper != token.GetLength() - 1)
value = token.SubStr(pHelper+1);

if (!ValidateToken(value, ACQUERY))
Expand Down
1 change: 1 addition & 0 deletions test/remote-url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ BOOST_AUTO_TEST_CASE(format)

url = new Url("/foo/bar/index.php?blaka");
BOOST_CHECK(new Url(url->Format()));
BOOST_CHECK(url->Format() == "/foo/bar/index.php?blaka");

url = new Url("/");
BOOST_CHECK(url->Format() == "/");
Expand Down

0 comments on commit 2ef6642

Please sign in to comment.