1818
1919package io .undertow .servlet .spec ;
2020
21- import io .undertow .UndertowOptions ;
2221import io .undertow .security .api .SecurityContext ;
2322import io .undertow .security .idm .Account ;
2423import io .undertow .server .HttpServerExchange ;
5655import java .io .UnsupportedEncodingException ;
5756import java .net .InetAddress ;
5857import java .net .InetSocketAddress ;
59- import java .net .URLDecoder ;
6058import java .nio .charset .Charset ;
6159import java .nio .charset .StandardCharsets ;
6260import 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