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

Route matching problems if %+ already populated (issue 1187) #1188

Merged
merged 1 commit into from
Jun 13, 2018

Conversation

bigpresh
Copy link
Member

This is for Issue #1187.

It's not safe to look at %+ without first having checked whether the regex
matched successfully or not. Otherwise, we might see keys from a previous regex
match, because %+ is only cleared after a successful match.

(perldoc perlvar confirms, "Note: "%-" and "%+" are tied views into a common
internal hash associated with the last successful regular expression.")

Dancer2 doesn't have problems here, as it already returns immediately if the
regex didn't match, the same way this change does.

Note: I think this would only happen via certain deployment methods, and if
there was an earlier route which used named captures.

In particular, we never had any problems in our large API app's comprehensive
test suite when we used Dancer::Test. We've re-worked our testing framework to
use Plack::Test, partially in readyness to switch to Dancer2, and started
getting weird failures which were tracked down to incorrect route matching, and
this was the cause.

This is for Issue #1187.

It's not safe to look at `%+` without first having checked whether the regex
matched successfully or not.  Otherwise, we might see keys from a previous regex
match, because `%+` is only cleared after a successful match.

(perldoc perlvar confirms, "Note: "%-" and "%+" are tied views into a common
internal hash associated with the last successful regular expression.")

Dancer2 doesn't have problems here, as it already returns immediately if the
regex didn't match, the same way this change does.

Note: I think this would only happen via certain deployment methods, and if
there was an earlier route which used named captures.

In particular, we never had any problems in our large API app's comprehensive
test suite when we used Dancer::Test.  We've re-worked our testing framework to
use Plack::Test, partially in readyness to switch to Dancer2, and started
getting weird failures which were tracked down to incorrect route matching, and
this was the cause.
@bigpresh bigpresh merged commit 51e4206 into devel Jun 13, 2018
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.

1 participant