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

Fixing #9517 - bad url-pattern prefix match behavior #9518

Merged
merged 7 commits into from
Mar 20, 2023

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Mar 17, 2023

New testcase to ensure we don't have a regression on this behavior.
Restore a prefix matching loop that we previously had in Jetty 10.0.13

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime added Bug For general bugs on Jetty side Specification For all industry Specifications (IETF / Servlet / etc) labels Mar 17, 2023
@joakime joakime added this to the 10.0.x milestone Mar 17, 2023
@joakime joakime self-assigned this Mar 17, 2023
@joakime joakime linked an issue Mar 17, 2023 that may be closed by this pull request
@@ -223,13 +230,13 @@ public MatchedResource<E> getMatched(String path)
// Loop 3: "foo"
while ((i = path.indexOf('.', i + 1)) > 0)
{
prefix = _suffixMap.get(path, i + 1, path.length() - i - 1);
if (prefix == null)
MappedResource<E> suffix = _suffixMap.get(path, i + 1, path.length() - i - 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just renamed "prefix" here to "suffix" to be more clear about usage.

joakime and others added 2 commits March 17, 2023 14:34
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
More efficient loop.
Also optimized mapping

Signed-off-by: gregw <gregw@webtide.com>
@gregw
Copy link
Contributor

gregw commented Mar 18, 2023

@joakime I pushed an update to the loop that uses the length of the last match to improve the search for a shorter match. Much better than searching on every string length.

However, I don't like the magic number 3 (which is the "/*" minus 1 more), but I think it works. Could perhaps have more testing of 1 char patterns?

Also there was another optimized prefix match that needs same fix.

improved test

Signed-off-by: gregw <gregw@webtide.com>
gregw
gregw previously approved these changes Mar 19, 2023
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@sbordet sbordet merged commit 17aa0c5 into jetty-10.0.x Mar 20, 2023
@sbordet sbordet deleted the fix/10.0.x/pathmatching-root branch March 20, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side Specification For all industry Specifications (IETF / Servlet / etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jetty 10.0.14 uses wrong pathSpec for request
3 participants