[gnome-shell] [messageTray] Fix text with ampersands not being displayed



commit 79fe60e6fb2d3aa1a5389f50b1840503cd3b723d
Author: Florian Müllner <fmuellner src gnome org>
Date:   Sat Feb 20 04:28:47 2010 +0100

    [messageTray] Fix text with ampersands not being displayed
    
    If the notification body contains '&' it ends up empty and a warning
    about an invalid entity is printed on stderr, so our escape code must
    handle ampersands as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=607375

 js/ui/messageTray.js |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 039685a..06dd250 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -27,9 +27,12 @@ const State = {
 };
 
 function _cleanMarkup(text) {
+    // Support &amp;, &quot;, &apos;, &lt; and &gt;, escape all other
+    // occurrences of '&'.
+    let _text = text.replace(/&(?!amp;|quot;|apos;|lt;|gt;)/g, "&amp;");
     // Support <b>, <i>, and <u>, escape anything else
     // so it displays as raw markup.
-    return text.replace(/<(\/?[^biu]>|[^>\/][^>])/g, "&lt;$1");
+    return _text.replace(/<(\/?[^biu]>|[^>\/][^>])/g, "&lt;$1");
 }
 
 // Notification:
@@ -295,7 +298,6 @@ Notification.prototype = {
     popIn: function() {
         if (this.actor.row_count <= 1)
             return false;
-
         Tweener.addTween(this._bannerLabel,
                          { opacity: 255,
                            time: ANIMATION_TIME,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]