Skip to content

Commit

Permalink
When generating a redirect to a directory in the Default Servlet, avo…
Browse files Browse the repository at this point in the history
…id generating a protocol relative redirect.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1840057 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Sep 4, 2018
1 parent 907d78d commit b76e1df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions java/org/apache/catalina/servlets/DefaultServlet.java
Expand Up @@ -1106,6 +1106,10 @@ private void doDirectoryRedirect(HttpServletRequest request, HttpServletResponse
location.append('?');
location.append(request.getQueryString());
}
// Avoid protocol relative redirects
while (location.length() > 1 && location.charAt(1) == '/') {
location.deleteCharAt(0);
}
response.sendRedirect(response.encodeRedirectURL(location.toString()));
}

Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Expand Up @@ -119,6 +119,10 @@
specify a content type, do not force the content type to
<code>application/x-octet-stream</code>. (markt)
</fix>
<fix>
When generating a redirect to a directory in the Default Servlet, avoid
generating a protocol relative redirect. (markt)
</fix>
</changelog>
</subsection>
<subsection name="Coyote">
Expand Down

0 comments on commit b76e1df

Please sign in to comment.