Skip to content

Commit 52577d1

Browse files
committed
Revert "[UNDERTOW-1591][UNDERTOW-2123] Always decode pathInfo and servletPath as required by Servlet specification."
This reverts commit f49d1d9.
1 parent d24d91f commit 52577d1

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

servlet/src/main/java/io/undertow/servlet/spec/HttpServletRequestImpl.java

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package io.undertow.servlet.spec;
2020

21-
import io.undertow.UndertowOptions;
2221
import io.undertow.security.api.SecurityContext;
2322
import io.undertow.security.idm.Account;
2423
import io.undertow.server.HttpServerExchange;
@@ -56,7 +55,6 @@
5655
import java.io.UnsupportedEncodingException;
5756
import java.net.InetAddress;
5857
import java.net.InetSocketAddress;
59-
import java.net.URLDecoder;
6058
import java.nio.charset.Charset;
6159
import java.nio.charset.StandardCharsets;
6260
import java.nio.charset.UnsupportedCharsetException;
@@ -291,29 +289,16 @@ public String getMethod() {
291289

292290
@Override
293291
public String getPathInfo() {
294-
final ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
295-
return match != null ? decodeURL(match.getRemaining()) : null;
296-
}
297-
298-
private String decodeURL(final String s) {
299-
try {
300-
return s != null && s.length() > 0 ? URLDecoder.decode(s, getURLEncoding()) : s;
301-
} catch (UnsupportedEncodingException ignored) {
302-
throw new IllegalStateException(); // cannot happen
292+
ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
293+
if (match != null) {
294+
return match.getRemaining();
303295
}
304-
}
305-
306-
private String getURLEncoding() {
307-
return exchange.getConnection().getUndertowOptions().get(UndertowOptions.URL_CHARSET, StandardCharsets.UTF_8.name());
296+
return null;
308297
}
309298

310299
@Override
311300
public String getPathTranslated() {
312-
ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
313-
if (match != null) {
314-
return servletContext.getRealPath(match.getRemaining());
315-
}
316-
return null;
301+
return servletContext.getRealPath(getPathInfo());
317302
}
318303

319304
@Override
@@ -453,8 +438,11 @@ public StringBuffer getRequestURL() {
453438

454439
@Override
455440
public String getServletPath() {
456-
final ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
457-
return match != null ? decodeURL(match.getMatched()) : "";
441+
ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
442+
if (match != null) {
443+
return match.getMatched();
444+
}
445+
return "";
458446
}
459447

460448
@Override
@@ -1183,11 +1171,7 @@ public String getOriginalServletPath() {
11831171
if(uri != null) {
11841172
return uri;
11851173
}
1186-
ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
1187-
if (match != null) {
1188-
return match.getMatched();
1189-
}
1190-
return "";
1174+
return getServletPath();
11911175
}
11921176

11931177
public String getOriginalPathInfo() {
@@ -1199,11 +1183,7 @@ public String getOriginalPathInfo() {
11991183
if(uri != null) {
12001184
return uri;
12011185
}
1202-
ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch();
1203-
if (match != null) {
1204-
return match.getRemaining();
1205-
}
1206-
return null;
1186+
return getPathInfo();
12071187
}
12081188

12091189
public String getOriginalContextPath() {

0 commit comments

Comments
 (0)