Browse Source

Quote values in nowplaying substitutions

Fixes issue 3628

Change-Id: Iecf1a4fcc624eac4d8e2ecfc4b7f5e4499b5b972
Reviewed-on: http://gerrit.dmdirc.com/636
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Automatic-Compile: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Chris Smith 14 years ago
parent
commit
4e5b896835
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java

+ 5
- 3
src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java View File

@@ -38,6 +38,7 @@ import com.dmdirc.plugins.PluginManager;
38 38
 import java.util.ArrayList;
39 39
 import java.util.Collections;
40 40
 import java.util.List;
41
+import java.util.regex.Matcher;
41 42
 
42 43
 /**
43 44
  * Plugin that allows users to advertise what they're currently playing or
@@ -183,7 +184,7 @@ public class NowPlayingPlugin extends Plugin implements ActionListener  {
183 184
     private void removePlugin(final PluginInfo target) {
184 185
         final Plugin targetPlugin = target.getPlugin();
185 186
         if (targetPlugin instanceof MediaSource) {
186
-            sources.remove(targetPlugin);
187
+            sources.remove((MediaSource) targetPlugin);
187 188
         }
188 189
         
189 190
         if (targetPlugin instanceof MediaSourceManager) {
@@ -268,14 +269,15 @@ public class NowPlayingPlugin extends Plugin implements ActionListener  {
268 269
      * Sanitises the specified String so that it may be used as the replacement
269 270
      * in a call to String.replaceAll. Namely, at present, this method returns
270 271
      * an empty String if it is passed a null value; otherwise the input is
271
-     * returned.
272
+     * quoted for use as a replacement in the
273
+     * {@link String#replaceAll(java.lang.String, java.lang.String)} method.
272 274
      *
273 275
      * @param input The string to be sanitised
274 276
      * @return A sanitised version of the String
275 277
      * @since 0.6.3
276 278
      */
277 279
     protected static String sanitise(final String input) {
278
-        return input == null ? "" : input;
280
+        return input == null ? "" : Matcher.quoteReplacement(input);
279 281
     }
280 282
     
281 283
     /**

Loading…
Cancel
Save