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 matching issue with placeholders #365

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

rossbacher
Copy link
Collaborator

@rossbacher rossbacher commented Jun 27, 2023

If a match template contained a placeholder in a path element (e.g. host) and the to be matched URL element matched but was just shorter than the template (before the placeholder end) it would lead to an AIOOB Exception.

e.g.

template: scheme://{some_value(allowed|values)}somethinglonger/one/{param}/three
url to match scheme://longer/one/param/three

Scheme matches
host (will start to match from back) and it matches char by char bur the one in the template is longer (before the placeholder) in this case we need to avoid the AIOOB in url segment and it also does not match.

Andreas Rossbacher added 2 commits June 27, 2023 15:07
…than the text before the placeholder in the template.
…than the text before the placeholder in the template.
// e.g. template value: "{something}longer" and valueToMatch: "onger". As we compare
// from back all the chars match but the template value is longer so as soon as we reach
// the end of valueToMatch before we reach the placeholder end char we need to abort.
if (k < 0 || byteArray[valueStartPos + j] != valueToMatch[k]) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the fix.

@rossbacher rossbacher merged commit 22ac5cd into master Jun 27, 2023
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.

2 participants