Skip to content

Commit

Permalink
Merge pull request Netflix#198 from ausmith/1.x
Browse files Browse the repository at this point in the history
Specially handle encoded ampersands in query string
  • Loading branch information
chris-h-phillips committed Jan 17, 2016
2 parents b8e6002 + f9a462b commit 53bdeb0
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,24 @@ class SimpleHostRoutingFilter extends ZuulFilter {
return ""
}

String decodedQueryString = URLDecoder.decode(currentQueryString, encoding)
return new URI(null, null, null, decodedQueryString, null).toString()
String rebuiltQueryString = ""
for (String keyPair : currentQueryString.split("&")) {
if (rebuiltQueryString.length() > 0) {
rebuiltQueryString = rebuiltQueryString + "&"
}
def (name,value) = keyPair.split("=", 2)
if (value != null) {
value = URLDecoder.decode(value, encoding)
value = new URI(null, null, null, value, null).toString().substring(1)
value = value.replaceAll('&', '%26')
rebuiltQueryString = rebuiltQueryString + name + "=" + value
} else {
name = URLDecoder.decode(name, encoding)
value = new URI(null, null, null, value, null).toString().substring(1)
rebuiltQueryString = rebuiltQueryString + value
}
}
return "?" + rebuiltQueryString
}

HttpHost getHttpHost() {
Expand Down

0 comments on commit 53bdeb0

Please sign in to comment.