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

Mapping Rule: Use unescaped rule #1123

Merged
merged 2 commits into from
Oct 15, 2019
Merged

Conversation

eloycoto
Copy link
Contributor

@eloycoto eloycoto commented Oct 3, 2019

This commit address the issues with the mapping rules that normalizes
the URL and mapping rules are not matching correctly.

Fix #1002
Fix THREESCALE-3468

Signed-off-by: Eloy Coto eloy.coto@gmail.com

@eloycoto eloycoto requested a review from a team as a code owner October 3, 2019 15:12
@eloycoto eloycoto changed the title Mapping Rule: Use unescaped rule WIP::Mapping Rule: Use unescaped rule Oct 3, 2019
@@ -242,7 +242,7 @@ function _M:rewrite(service, context)
return errors.no_credentials(service)
end

local usage, matched_rules = service:get_usage(ngx.req.get_method(), ngx.var.uri)
local usage, matched_rules = service:get_usage(ngx.req.get_method(), ngx.var.request_uri)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK $request_uri includes arguments and $uri doesn't.
The docs are explicit about $request_uri, but not $uri.

So, I think the query parameters should be stripped out from ngx.var.request_uri first (e.g. ?q=query).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP PR, ngx.var.set_uri() modified ngx.var.uri and no request.uri, so it's not valid at all ;-)

@eloycoto eloycoto force-pushed the REQUEST_URI_ISSES branch 16 times, most recently from 74211bd to 259000f Compare October 8, 2019 13:08
@eloycoto eloycoto requested a review from mayorova October 8, 2019 13:09
@eloycoto eloycoto changed the title WIP::Mapping Rule: Use unescaped rule Mapping Rule: Use unescaped rule Oct 8, 2019
@eloycoto eloycoto force-pushed the REQUEST_URI_ISSES branch 4 times, most recently from 18e82bd to 2edffe0 Compare October 8, 2019 14:19
ngx.escape functions are not valid to encode the URI, due to it also
encodes characters like: /, ?, etc.. This commit uses the ngx_string.h
ngx_escape function that it's what NGINX uses internally and provide the
right setup for this use case.

Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
@eloycoto eloycoto merged commit e584143 into 3scale:master Oct 15, 2019
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

Successfully merging this pull request may close these issues.

escaped characters in the mapping rules are not honoured
3 participants