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

fix(router) anchor regex paths in traditional_compatible mode #9394

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

flrgh
Copy link
Contributor

@flrgh flrgh commented Sep 7, 2022

The traditional router would use the a (anchor) flag when evaluating input to ensure regex paths only match from the start of the string.

Given the route path /prefix/[0-9]+ (<=2.8) or ~/prefix/[0-9]+ (>=3.0):

request match
GET /prefix/123 yes
GET /extra/prefix/123 no

This updates the traditional_compatible router to replicate the same behavior. The underlying atc router library does not support regex flags, so we accomplish this by prepending the regex with ^.

The traditional router would use the `a` (anchor) flag when evaluating
input to ensure regex paths only match from the start of the string.

Given the route path `/prefix/[0-9]+`:

GET /prefix/123       => match
GET /extra/prefix/123 => no match

This updates the traditional_compatible router to replicate the same
behavior. The underlying atc router library does not support regex
flags, so we accomplish this by prepending the regex with `^`.
@flrgh flrgh added this to the 3.0 milestone Sep 7, 2022
@flrgh flrgh requested a review from a team as a code owner September 7, 2022 19:36
Copy link
Contributor

@aboudreault aboudreault left a comment

Choose a reason for hiding this comment

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

LGTM, better to wait a second approval from someone that know well the new router. @dndx

@tyler-ball tyler-ball merged commit f3bc5cc into master Sep 7, 2022
@flrgh flrgh deleted the fix/router-trad-compat-regex-anchor branch September 7, 2022 22:20
dndx pushed a commit that referenced this pull request Oct 10, 2022
* rename `atc_compat.lua` to `compat.lua`
* add a new file `expressions.lua`
* move lots of logic into `atc.lua`
* rename `get_atc` to `get_expression`
* rename `route_priority` to `get_priority`
* rename `atc_escape_str `to `escape_str`
* remove function `paths_resort`
* transplant #9327 
* transplant #9329 
* transplant #9343
* transplant #9346
* transplant #9357
* transplant #9389
* transplant #9394
* transplant #9451
* transplant #9480
oowl pushed a commit to oowl/kong that referenced this pull request Oct 12, 2022
* rename `atc_compat.lua` to `compat.lua`
* add a new file `expressions.lua`
* move lots of logic into `atc.lua`
* rename `get_atc` to `get_expression`
* rename `route_priority` to `get_priority`
* rename `atc_escape_str `to `escape_str`
* remove function `paths_resort`
* transplant Kong#9327 
* transplant Kong#9329 
* transplant Kong#9343
* transplant Kong#9346
* transplant Kong#9357
* transplant Kong#9389
* transplant Kong#9394
* transplant Kong#9451
* transplant Kong#9480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants