Skip to content

Commit

Permalink
Fix #7891 regex pathInfo (#7892)
Browse files Browse the repository at this point in the history
Fix 7891 regex pathInfo

+ Use the pathSpec methods to set servletPath and pathInfo when possible

Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw authored and joakime committed Oct 6, 2022
1 parent 024a053 commit 351fe53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Expand Up @@ -98,7 +98,6 @@ else if (pathSpec != null)
}
else
{
// TODO can we do better for RegexPathSpec
_mappingMatch = null;
_matchValue = "";
_servletPath = pathInContext;
Expand Down
Expand Up @@ -64,6 +64,7 @@
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.http.pathmap.RegexPathSpec;
import org.eclipse.jetty.http.pathmap.MatchedPath;
import org.eclipse.jetty.http.pathmap.RegexPathSpec;
import org.eclipse.jetty.http.pathmap.ServletPathSpec;
Expand Down Expand Up @@ -469,7 +470,7 @@ public void testMultiPart() throws Exception
return s.count() == 2;
}
};

_server.stop();
_context.setContextPath("/foo");
_context.setResourceBase(".");
Expand Down Expand Up @@ -1686,11 +1687,11 @@ public void testCookieLeak() throws Exception
assertEquals("value", cookies[0]);
assertNull(cookies[1]);
}

/**
* Test that multiple requests on the same connection with different cookies
* do not bleed cookies.
*
*
* @throws Exception
*/
@Test
Expand Down Expand Up @@ -1733,7 +1734,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
response = HttpTester.parseResponse(lep.getResponse());
checkCookieResult(sessionId3, new String[] {sessionId1, sessionId2}, response.getContent());
}

@Test
public void testHashDOSKeys() throws Exception
{
Expand Down Expand Up @@ -2402,7 +2403,7 @@ public void clearAttributes()
{
}
}

private static void checkCookieResult(String containedCookie, String[] notContainedCookies, String response)
{
assertNotNull(containedCookie);
Expand Down
Expand Up @@ -79,7 +79,7 @@ public void testMapping() throws Exception
assertThat(response, containsString("servletPath='/test/info'"));
assertThat(response, containsString("pathInfo='null'"));
assertThat(response, containsString("mapping.mappingMatch='null'"));
assertThat(response, containsString("mapping.matchValue=''"));
assertThat(response, containsString("mapping.matchValue='test/info'"));
assertThat(response, containsString("mapping.pattern='^/test/.*$'"));
}

Expand All @@ -96,7 +96,7 @@ public void testForward() throws Exception
assertThat(response, containsString("servletPath='/Test/info'"));
assertThat(response, containsString("pathInfo='null'"));
assertThat(response, containsString("mapping.mappingMatch='null'"));
assertThat(response, containsString("mapping.matchValue=''"));
assertThat(response, containsString("mapping.matchValue='Test/info'"));
assertThat(response, containsString("mapping.pattern='^/[Tt]est(/.*)?'"));
}

Expand All @@ -113,7 +113,7 @@ public void testInclude() throws Exception
assertThat(response, containsString("servletPath='/include'"));
assertThat(response, containsString("pathInfo='null'"));
assertThat(response, containsString("mapping.mappingMatch='null'"));
assertThat(response, containsString("mapping.matchValue=''"));
assertThat(response, containsString("mapping.matchValue='include'"));
assertThat(response, containsString("mapping.pattern='^/include$'"));
}

Expand Down

0 comments on commit 351fe53

Please sign in to comment.