From 94b12315f151ea1ada0be2c2353cdc29cfaa206d Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 2 Sep 2014 13:16:56 -0500 Subject: [PATCH] notifier: Escape ampersands in notification body The One True notification daemon will not display notification body text if it includes an ampersand. To prevent this, ampersands must be XML-escaped. --- src/notifier.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/notifier.vala b/src/notifier.vala index f98bac8..358cf4d 100644 --- a/src/notifier.vala +++ b/src/notifier.vala @@ -73,18 +73,22 @@ namespace MpdNotify { private void send_notification(string summary, string? body = null, string? icon = null, int timeout = 2000) { + string thebody = null; + if (body != null) { + thebody = body.replace("&", "&"); + } if (notif == null) { if (Notify.is_initted()) { Notify.uninit(); } Notify.init("mpdnotify"); - notif = new Notify.Notification(summary, body, icon); + notif = new Notify.Notification(summary, thebody, icon); notif.set_timeout(timeout); notif.closed.connect(() => { notif = null; }); } else { - notif.update(summary, body, icon); + notif.update(summary, thebody, icon); } try { notif.show();