-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@@ -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); |
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.
Just renamed "prefix" here to "suffix" to be more clear about usage.
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
More efficient loop. Also optimized mapping Signed-off-by: gregw <gregw@webtide.com>
@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>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java
Outdated
Show resolved
Hide resolved
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java
Outdated
Show resolved
Hide resolved
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java
Outdated
Show resolved
Hide resolved
jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java
Outdated
Show resolved
Hide resolved
jetty-http/src/test/java/org/eclipse/jetty/http/pathmap/PathMappingsTest.java
Show resolved
Hide resolved
jetty-http/src/test/java/org/eclipse/jetty/http/pathmap/PathMappingsTest.java
Show resolved
Hide resolved
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
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