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

restore old ServletPathMapping even for include dispatch types #5075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public Object getAttribute(String key)
case INCLUDE_CONTEXT_PATH:
{
ContextHandler.Context context = _baseRequest.getContext();
return context == null ? null : context.getContextHandler().getContextPathEncoded();
return context == null ? null : context.getContextHandler().getRequestContextPath();
}
case INCLUDE_QUERY_STRING:
return _query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,14 +794,7 @@ public String getContextPath()
if (context == null)
return null;

// For some reason the spec requires the context path to be encoded (unlike getServletPath).
String contextPath = context.getContextHandler().getContextPathEncoded();

// For the root context, the spec requires that the empty string is returned instead of the leading '/'
// which is included in the pathInContext
if (URIUtil.SLASH.equals(contextPath))
return "";
return contextPath;
return context.getContextHandler().getRequestContextPath();
}

/** Get the path in the context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,6 @@ public void doScope(String target, Request baseRequest, HttpServletRequest reque
// Get the base requests
final ServletPathMapping old_servlet_path_mapping = baseRequest.getServletPathMapping();

DispatcherType type = baseRequest.getDispatcherType();

ServletHolder servletHolder = null;
UserIdentity.Scope oldScope = null;

Expand Down Expand Up @@ -472,8 +470,7 @@ public void doScope(String target, Request baseRequest, HttpServletRequest reque
if (oldScope != null)
baseRequest.setUserIdentityScope(oldScope);

if (!(DispatcherType.INCLUDE.equals(type)))
baseRequest.setServletPathMapping(old_servlet_path_mapping);
baseRequest.setServletPathMapping(old_servlet_path_mapping);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -108,12 +107,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

private void dumpAttrs(String tag, HttpServletRequest req, ServletOutputStream out) throws IOException
{
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_CONTEXT_PATH,
req.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH)));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_SERVLET_PATH,
req.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH)));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_PATH_INFO,
req.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO)));
String contextPath = (String)req.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH);
String servletPath = (String)req.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
String pathInfo = (String)req.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);

out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_CONTEXT_PATH, contextPath));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_SERVLET_PATH, servletPath));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_PATH_INFO, pathInfo));
}
}

Expand Down Expand Up @@ -221,7 +221,6 @@ private String getPotentialBody(HttpURLConnection connection)
}
}

@Disabled // TODO: complete merge of PR #5058.
@Test
public void testIncludeAttributes() throws IOException
{
Expand Down