Skip to content

Commit f9f1473

Browse files
committed
When generating a redirect to a directory in the Default Servlet, avoid generating a protocol relative redirect.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.5.x/trunk@1840056 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1713b25 commit f9f1473

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

java/org/apache/catalina/servlets/DefaultServlet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,10 @@ private void doDirectoryRedirect(HttpServletRequest request, HttpServletResponse
11541154
location.append('?');
11551155
location.append(request.getQueryString());
11561156
}
1157+
// Avoid protocol relative redirects
1158+
while (location.length() > 1 && location.charAt(1) == '/') {
1159+
location.deleteCharAt(0);
1160+
}
11571161
response.sendRedirect(response.encodeRedirectURL(location.toString()));
11581162
}
11591163

webapps/docs/changelog.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
<fix>
7777
<bug>62667</bug>: Add recursion to rewrite substitution parsing. (remm)
7878
</fix>
79+
<fix>
80+
When generating a redirect to a directory in the Default Servlet, avoid
81+
generating a protocol relative redirect. (markt)
82+
</fix>
7983
</changelog>
8084
</subsection>
8185
<subsection name="Coyote">

0 commit comments

Comments
 (0)