File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
java/src/main/java/com/genexus Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change 55import com .genexus .util .GXServices ;
66
77import java .io .File ;
8+ import java .net .URI ;
89import java .net .URLDecoder ;
910import java .nio .charset .StandardCharsets ;
1011import java .util .regex .Matcher ;
@@ -239,18 +240,28 @@ public static String pathToUrl(String path, boolean forceAbsPath)
239240 }
240241
241242 private static String safeDecodeUrl (String uri ) {
242- if (uri == null || uri .isEmpty ()) {
243+ if (uri == null || uri .isEmpty ())
243244 return uri ;
244- }
245- boolean hasEncodedSegments =
246- uri .matches (".*%[0-9A-Fa-f]{2}.*" );
247-
248- if (!hasEncodedSegments ) {
249- return uri ;
250- }
251245 try {
252- return URLDecoder .decode (uri );
253- } catch (IllegalArgumentException e ) {
246+ URI u = new URI (uri );
247+ String rawPath = u .getRawPath ();
248+ if (rawPath == null )
249+ return uri ;
250+
251+ boolean hasEncodedSegments = rawPath .matches (".*%[0-9A-Fa-f]{2}.*" );
252+ if (!hasEncodedSegments ) {
253+ return uri ;
254+ }
255+ String decodedPath = java .net .URLDecoder .decode (rawPath , "UTF-8" );
256+ return new URI (
257+ u .getScheme (),
258+ u .getAuthority (),
259+ decodedPath ,
260+ u .getRawQuery (),
261+ null
262+ ).toString ();
263+
264+ } catch (Exception e ) {
254265 return uri ;
255266 }
256267 }
You can’t perform that action at this time.
0 commit comments