-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(router) add decode_uri_captures parameter #8064
feat(router) add decode_uri_captures parameter #8064
Conversation
kong.conf.default
Outdated
# - `on`: Request URI normalization is enabled. | ||
# - `off`: Request URI normalization is disabled. | ||
# | ||
# By default this value is set to `on`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalization and decoding are two different things and have different consequences.
this description doesn't explain if the process is done only for route matching or if it affects the upstream request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your advice,
now I am considering only using the unnormalized req uri to get the match_t.matches.uri_captures instead.
Then it should not affect route matching and upstream request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace normalize_req_uri
with normalize_uri_captures
to only affect captured request URI.
Please help check again, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still calling the process "normalization", but it's decoding. i guess the function was badly named, but this change makes the error visible in the documentation and parameter name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review!
Just submit a commit to rename normalize_uri_captures to decode_uri_captures.
Replace When decode_uri_captures is set as When decode_uri_captures is set as If kong failed to get uri_captures, it will nomalize req_uri and regex to get decoded uri_captures instead Now customers are able to get undecoded uri_captures by setting |
Add a new parameter normalize-req-uri to decide whether to normalize the request URI or not. New feature for Kong#7913
Use a self parameter(normalize_req_uri) of kong.router to load the new parameter. It will be easier to add a new route parameter to control the URI normalization behavior in the future. New feature for Kong#7913
Modify the 'if condition' for the case self.normalize_req_uri is nil to pass the original unit test. Add unit tests. New feature for Kong#7913
The normalize-req-uri may affect route matching and the upstream request. Replace normalize-req-uri with normalize_uri_captures to only affect captured request URI. If normalize_uri_captures is set to on, the behavior is same as previous. If normalize_uri_captures is set to off, it will try to the capture the request URI without URI normalization. Check more details in normalize_uri_captures part from kong.conf.default. New feature for Kong#7913
7edbb03
to
f8ceec8
Compare
Rebased |
Rename normalize_uri_captures to decode_uri_captures New feature for Kong#7913
Renamed normalize_uri_captures to decode_uri_captures |
I don't think we want this to be configuration option. We just need to do proper thing. |
@dndx We need to make a decision on if we want to proceed or not here. |
Is this pull request still relevant with Kong Gateway 3.x? |
We decided to not go this way, instead we did #8140 |
Add a new parameter
decode_uri_captures
to decide whether to normalize the captured request URI after route matching.New feature for #7913
Summary
Add a new parameter
decode_uri_captures
to decide whether to normalize the captured request URI after route matching.Only allow setting
on
oroff
:on
: Captured request URI decoding is enabled.off
: Captured request URI decoding is disabled.By default, this value is set as
on
.Examples of
decode_uri_captures = on
behavior:/plain/(a%2Eb%20c)/(.*)
and the request URI is/plain/a%2Eb%20c/a%2Eb%20c
, the captured request URI is decoded as/plain/a.b c/a.b c
./plain/(a.b c)/(.*)
and the request URI is/plain/a%2Eb%20c/a%2Eb%20c
, the captured request URI is decoded as/plain/a.b c/a.b c
.Examples of
decode_uri_captures = off
/plain/(a%2Eb%20c)/(.*)
and the request URI is/plain/a%2Eb%20c/a%2Eb%20c
, the captured request URI is/plain/a%2Eb%20c/a%2Eb%20c
without URI decoding./plain/(a.b c)/(.*)
and the request URI is/plain/a%2Eb%20c/a%2Eb%20c
, the request URI can not match the route path without URI decoding. As a result, the captured request URI is decoded as/plain/a.b c/a.b c
.Full changelog
decode_uri_captures
to only decide whether to decode captured request URI or not (Do not have affect for route matching and upstream request)Issues resolved
Fix #7913