acabal/thunderbird-addons

Enhanced Desktop Notification: message text not set because of malformed HTML

Closed this issue · 9 comments

So, apparently notify-send will accept and render some HTML tags in the message body of a notification. When Enhanced Desktop Notification sets the message to include the sender this may be Person Name <person.email@example.com>, which can trip up notify-send.

Here's the error from my log:

xfce4-notifyd: Failed to set text 'Banana <banana@example.com>' from markup due to error parsing markup: Error on line 1 char 29: 'banana@example.com' is not a valid name: '@'

Can you HTML escape the message body before sending it to notify-send?

That doesn't seem to be how notify-send behaves on Ubuntu 16.04. I can send it HTML and it prints the tags without problems. If I escape them, then it prints Banana &lt;banana@example.com&gt; which is obviously wrong. So maybe there has to be some detection of which version of notify-send is installed, but I don't have an XFCE machine available at the moment right now. If you'd like to work on this please go for it!

I've tried to find out when notify-send started supporting HTML tags so I could add a version check, but I can't find it anywhere. Furthermore some of the AskUbuntu Q&A I found suggests that html should be supported and tags should not be ignored. The spec defines this behaviour where implementations are encouraged to support a few html tags, but even if they don't they should filter out unsupported tags (and I guess interpret &lt;, &gt; and &amp;). Can you let me know the version of your notify-send? Maybe we can figure out a way around the issue.

Hmm, I had a theory but I just disproved it. The theory was that notify-send will already html escape a message when the notification server implementation says it's capable of handling markup with the "body-markup" message. On Ubuntu you probably use NotifyOSD, which will say that it accepts text with markup. But I just sent a DBus message to my xfce4-notifyd, and it also gives "body-markup" as a capability, so unless I'm missing something this isn't the difference between our machines.

Here's my version of notify-send:

$> notify-send --version
notify-send 0.7.6

Well, all I read about this suggests that on Ubuntu it should be able to receive escaped html and display it properly. Here's a couple more questions to see if we can zero in on the problem:

  1. If you try notify-send title 'Hello <i>world</i>', are the tags shown in the notification? Is world printed italic?
  2. Try notify-send title 'If x&lt;y then y is greater than x'. Does it display the < or keep the escaped version?
  3. What does the following give? dbus-send --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.GetCapabilities
  4. Can you check which notification server you use? Is it the standard NotifyOSD? Which version is it?
  1. Prints in italics
  2. Displays <
method return time=1501262549.674686 sender=:1.23 -> destination=:1.81 serial=381 reply_serial=2
   array [
      string "actions"
      string "body"
      string "body-markup"
      string "icon-static"
      string "persistence"
      string "sound"
   ]
  1. Not sure how to check that

Have you considered installing an Ubuntu virtual machine on your computer to play around with this stuff? Might be easier and more flexible for you.

Ok, so I tried a fresh install of Ubuntu 16.04 in a virtual machine. Which handles &lt; just fine, it displays <. But it doesn't do italics (although it does remove the tags). And this is definitely NotifyOSD. So you're using a different notification daemon I think (the dbus response message also suggests that).

My suggestion would be to use dbus-send --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.GetCapabilities to see if body-markup is supported by the notification daemon and if it is, then html-escape the body text (not the title text, that's always taken literally). And then see if that works for your system too. If not, I really need to I know what notification daemon you're using to figure this out.

I forgot to mention I use Ubuntu-Gnome so maybe they use a different program.

If you want to create a pull request with your proposed changes, I'd be happy to review it.

Closed due to inactivity.