summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <luke.macken@gmail.com>2010-04-05 20:57:23 +0000
committerLuke Macken <luke.macken@gmail.com>2010-04-05 20:57:23 +0000
commit18db1f2c01680a73d84c0f32d01dc1dc3cc72ec7 (patch)
treece3b894ccacfaf54cf72d8004d561e1f80cf9d31
parent98c4349c009df4e90d8c986ddd7a465a15f9b310 (diff)
downloadirssi-notify-18db1f2c01680a73d84c0f32d01dc1dc3cc72ec7.tar.gz
irssi-notify-18db1f2c01680a73d84c0f32d01dc1dc3cc72ec7.tar.xz
irssi-notify-18db1f2c01680a73d84c0f32d01dc1dc3cc72ec7.zip
Sanitise both $message AND $summary.
Thanks to Tom Adams for the patch. http://github.com/holizz/irssi-libnotify/commit/545f022f5dc855feed5b46fc4d94d02ab659c3eb git-svn-id: https://irssi-libnotify.googlecode.com/svn/trunk@33 291cbfae-0d27-0410-99d7-557b17e6fe3d
-rw-r--r--notify.pl15
1 files changed, 11 insertions, 4 deletions
diff --git a/notify.pl b/notify.pl
index eaa8d63..2d797f2 100644
--- a/notify.pl
+++ b/notify.pl
@@ -22,14 +22,21 @@ $VERSION = "0.01";
Irssi::settings_add_str('notify', 'notify_icon', 'gtk-dialog-info');
Irssi::settings_add_str('notify', 'notify_time', '5000');
+sub sanitize {
+ my ($text) = @_;
+ $text =~ s/&/&amp;/g; # That could have been done better.
+ $text =~ s/</&lt;/g;
+ $text =~ s/>/&gt;/g;
+ $text =~ s/'/&apos;/g;
+ return $text;
+}
+
sub notify {
my ($server, $summary, $message) = @_;
# Make the message entity-safe
- $message =~ s/&/&amp;/g; # That could have been done better.
- $message =~ s/</&lt;/g;
- $message =~ s/>/&gt;/g;
- $message =~ s/'/&apos;/g;
+ $summary = sanitize($summary);
+ $message = sanitize($message);
my $cmd = "EXEC - notify-send" .
" -i " . Irssi::settings_get_str('notify_icon') .