Skip to content

Commit

Permalink
Handle query params without an =
Browse files Browse the repository at this point in the history
If a query string contained a key pair without an `=` in the string then
it would cause an array out of bounds exception because the split was
not wrapped defensively to test for the presence of an `=` first.

Example: ?&abc=123&xyz
Split on `&` would look like: `['', 'abc=123', 'xyz']`
Both cases are now handled where the string is missing `=`
  • Loading branch information
ausmith committed Jan 21, 2016
1 parent f9a462b commit 11ae37f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,15 @@ class SimpleHostRoutingFilter extends ZuulFilter {
if (rebuiltQueryString.length() > 0) {
rebuiltQueryString = rebuiltQueryString + "&"
}
def (name,value) = keyPair.split("=", 2)
if (value != null) {

if (keyPair.contains("=")) {
def (name,value) = keyPair.split("=", 2)
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)
def value = URLDecoder.decode(keyPair, encoding)
value = new URI(null, null, null, value, null).toString().substring(1)
rebuiltQueryString = rebuiltQueryString + value
}
Expand Down

0 comments on commit 11ae37f

Please sign in to comment.