Przeglądaj źródła

Quote replacements in URL handler

Fixes issue 3669

Change-Id: I8e62f8494c8e30cae8c615cbfc546c454aa0bd38
Reviewed-on: http://gerrit.dmdirc.com/702
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.3b1
Chris Smith 14 lat temu
rodzic
commit
94cc28e7c3
1 zmienionych plików z 11 dodań i 9 usunięć
  1. 11
    9
      src/com/dmdirc/util/URLHandler.java

+ 11
- 9
src/com/dmdirc/util/URLHandler.java Wyświetl plik

@@ -37,6 +37,8 @@ import java.net.URL;
37 37
 import java.util.ArrayList;
38 38
 import java.util.Date;
39 39
 import java.util.List;
40
+import java.util.regex.Matcher;
41
+import java.util.regex.Pattern;
40 42
 
41 43
 /** Handles URLs. */
42 44
 public class URLHandler {
@@ -206,15 +208,15 @@ public class URLHandler {
206 208
             }
207 209
         }
208 210
 
209
-        newCommand = newCommand.replaceAll("\\$url", url.toString());
210
-        newCommand = newCommand.replaceAll("\\$fragment", fragment);
211
-        newCommand = newCommand.replaceAll("\\$host", host);
212
-        newCommand = newCommand.replaceAll("\\$path", path);
213
-        newCommand = newCommand.replaceAll("\\$port", port);
214
-        newCommand = newCommand.replaceAll("\\$query", query);
215
-        newCommand = newCommand.replaceAll("\\$protocol", protocol);
216
-        newCommand = newCommand.replaceAll("\\$username", username);
217
-        newCommand = newCommand.replaceAll("\\$password", password);
211
+        newCommand = newCommand.replaceAll("\\$url", Matcher.quoteReplacement(url.toString()));
212
+        newCommand = newCommand.replaceAll("\\$fragment", Matcher.quoteReplacement(fragment));
213
+        newCommand = newCommand.replaceAll("\\$host", Matcher.quoteReplacement(host));
214
+        newCommand = newCommand.replaceAll("\\$path", Matcher.quoteReplacement(path));
215
+        newCommand = newCommand.replaceAll("\\$port", Matcher.quoteReplacement(port));
216
+        newCommand = newCommand.replaceAll("\\$query", Matcher.quoteReplacement(query));
217
+        newCommand = newCommand.replaceAll("\\$protocol", Matcher.quoteReplacement(protocol));
218
+        newCommand = newCommand.replaceAll("\\$username", Matcher.quoteReplacement(username));
219
+        newCommand = newCommand.replaceAll("\\$password", Matcher.quoteReplacement(password));
218 220
 
219 221
         return newCommand;
220 222
     }

Ładowanie…
Anuluj
Zapisz