escape % in irssi messages
authorChristian Garbs <mitch@cgarbs.de>
Sun, 28 Dec 2008 11:52:13 +0000 (12:52 +0100)
committerRalf Ertzinger <sun@lain.camperquake.de>
Sun, 28 Dec 2008 21:22:40 +0000 (22:22 +0100)
xmlrtorrent.pl

index 3514100..7adc01f 100644 (file)
@@ -94,12 +94,15 @@ sub write_irssi {
     my @text = @_;
     my $output = $outputstack[0];
 
-    $text[0] = '%%mxmlrtorrent: %%n' . $text[0];
+    my $format = '%%mxmlrtorrent: %%n' . shift(@text);
+
+    # escape % in parameters from irssi
+    @text = grep { s/%/%%/g } @text;
 
     if (defined($output) and ref($output)) {
-        $output->print(sprintf(shift(@text), @text), MSGLEVEL_CLIENTCRAP);
+        $output->print(sprintf($format, @text), MSGLEVEL_CLIENTCRAP);
     } else {
-        Irssi::print(sprintf(shift(@text), @text));
+        Irssi::print(sprintf($format, @text));
     }
 
 }