Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.8.x url encoding of parameters in query #1480

Closed
patrickpierson opened this issue Aug 9, 2016 · 2 comments
Closed

0.8.x url encoding of parameters in query #1480

patrickpierson opened this issue Aug 9, 2016 · 2 comments

Comments

@patrickpierson
Copy link

On 0.8.3 (upgrading from 0.5.4) the query parameters get url encoded

After upgrading to 0.8.3 from 0.5.4 I noticed that a url that is returned by our api gets encoded by kong. Is there a reason for the change?

Steps To Reproduce

  1. curl https://domain.com/v1/endpoint?param1=test&param2=1.2.3 against 0.5.4

Result contains:

"self": "https://domain.com/v1/endpoint?param1=test&param2=1.2.3"
  1. curl curl https://domain.com/v1/endpoint?param1=test&param2=1.2.3 against 0.8.3

Result contains:

"self": "https://domain.com/v1/endpoint?param1=test&param2=1%2E2%2E3"
@thibaultcha
Copy link
Member

thibaultcha commented Aug 9, 2016

Between 0.5 and 0.8, we had #749 raised and had to percent-encode each querystring parameter. As explained there, since ngx.encode_args does not percent-encode some characters, we had to go with LuaSocket's url.escape, which is defined like this:

function _M.escape(s)
    return (string.gsub(s, "([^A-Za-z0-9_])", function(c)
        return string.format("%%%02x", string.byte(c))
    end))
end

Meaning it will also encode the (although unreserved) . character.

Tbh, I think your backend application should always be prepared to percent-decode querystring values anyways, since those can contain reserved characters.

@patrickpierson
Copy link
Author

Thanks for the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants