Skip to content

Commit 4fb4234

Browse files
committed
- Updated the decode() method in the URL class to handle unencoded "%" characters
git-svn-id: svn://192.168.0.80/JavaXT/javaxt-core@1595 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 717dabe commit 4fb4234

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/javaxt/utils/URL.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ public static LinkedHashMap<String, List<String>> parseJDBCParams(String params)
193193
//**************************************************************************
194194
private static String decode(String str){
195195
try{
196+
197+
//Replace unencoded "%" characters with "%25". The regex finds a "%"
198+
//but only those that are NOT followed by 2 hex characters (0-F),
199+
//then replaces with the ENCODED version of the % character "%25".
200+
//Credit: https://stackoverflow.com/a/18368345
201+
str = str.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
202+
203+
204+
//Decode the string with the URLDecoder
196205
if (str.contains("+")){
197206
StringBuilder out = new StringBuilder();
198207
while (str.contains("+")){

0 commit comments

Comments
 (0)