[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
This commit is contained in:
Florian Müllner 2010-02-20 04:28:47 +01:00
parent c793d7d0a4
commit 79fe60e6fb

View File

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