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/trunk@1840055 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Sep 4, 2018
1 parent 94155ef commit efb860b
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
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
<fix>
<bug>62667</bug>: Add recursion to rewrite substitution parsing. (remm)
</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 efb860b

Please sign in to comment.