Skip to content

Commit c5e92e7

Browse files
Sabrina Juarez GarciaBeta Bot
authored andcommitted
Cherry pick branch 'genexuslabs:feature/Update_AzureStorage_SDK' into beta
1 parent d520539 commit c5e92e7

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

java/src/main/java/com/genexus/GXDbFile.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.genexus.util.GXServices;
66

77
import java.io.File;
8+
import java.net.URI;
89
import java.net.URLDecoder;
910
import java.nio.charset.StandardCharsets;
1011
import 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
}

0 commit comments

Comments
 (0)