Skip to content

Commit

Permalink
Fix Url query without values
Browse files Browse the repository at this point in the history
fixes #12883
  • Loading branch information
Crunsher committed Oct 10, 2016
1 parent 486ad6c commit 3fe87de
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/remote/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ String Url::Format(bool print_credentials) const
else
param += "&";

// Just one (or one empty) value
if (kv.second.size() == 1) {
param += key;
param += kv.second[0].IsEmpty() ? Empty : "=" + Utility::EscapeString(kv.second[0], ACQUERY_ENCODE, false);
continue;
}

// Array
String temp;
for (const String s : kv.second) {
if (!temp.IsEmpty())
Expand All @@ -267,7 +275,8 @@ String Url::Format(bool print_credentials) const
if (kv.second.size() > 1)
temp += "[]";

temp += "=" + Utility::EscapeString(s, ACQUERY_ENCODE, false);
if (!s.IsEmpty())
temp += "=" + Utility::EscapeString(s, ACQUERY_ENCODE, false);
}
param += temp;
}
Expand Down Expand Up @@ -375,7 +384,7 @@ bool Url::ParseQuery(const String& query)
String key = token.SubStr(0, pHelper);
String value = Empty;

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

if (!ValidateToken(value, ACQUERY))
Expand Down

0 comments on commit 3fe87de

Please sign in to comment.