-
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
Issue #7748 - Backport of allow override of path mapping behavior in ServletContextHandler #7834
Conversation
Keep in mind that Jetty 9.4.x has the old EPL 1.0 license headers. |
@@ -140,7 +140,7 @@ public String getPathMatch(String path) | |||
Matcher matcher = getMatcher(path); | |||
if (matcher.matches()) | |||
{ | |||
if (matcher.groupCount() >= 1) | |||
if (_group == PathSpecGroup.PREFIX_GLOB && matcher.groupCount() >= 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.
What is the reason for this change?
This change is not present in 10 & 11.
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.
@lachlan-roberts my intention is to move this change forward into 10 & 11.
I believe it is needed to make the methods getPathMatch
and getPathInfo
symmetric.
Specifically I would expect either pathMatch==/test && pathInfo==/info
or pathMatch==/test/info && pathInfo==null
, but never pathMatch==/test && pathInfo==null
, since that loses information. Currently we get the later behavior!
So I have added the following test.
@Test
public void testPathInfo()
{
RegexPathSpec spec = new RegexPathSpec("^/test(/.*)?$");
assertTrue(spec.matches("/test/info"));
assertThat(spec.getPathMatch("/test/info"), equalTo("/test"));
assertThat(spec.getPathInfo("/test/info"), equalTo("/info"));
spec = new RegexPathSpec("^/[Tt]est(/.*)?$");
assertTrue(spec.matches("/test/info"));
assertThat(spec.getPathMatch("/test/info"), equalTo("/test/info"));
assertThat(spec.getPathInfo("/test/info"), nullValue());
}
Note that this issue was not apparent in 10 & 11, because they do not use these methods to set the servletPath and pathInfo, but rather work it out differently (I'll check exactly why when I port this change forward).
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.
The UriTemplatePathSpec has the same issue with the difference in behavior.
Example path spec ... /{first}/static/{other}
+ Backport of #7748 + Fix RegexPathSpec pathInfo + Fix UriTemplatePathSpec pathInfo + Test regression option to 93 behaviour Signed-off-by: Greg Wilkins <[email protected]>
2a56929
to
63baa1a
Compare
I just did a force push to squash this to 1 commit so I can start work on porting forward to 10, 11 etc. |
@joakime @lachlan-roberts review please |
backport and fix to 9.4 for #7748