dunst icon indicating copy to clipboard operation
dunst copied to clipboard

Backslashes are always interpreted as escape characters

Open fwsmit opened this issue 4 years ago • 6 comments

Example:

dunstify "test \ " "test \ " The second backslash disappears in the notification.

Even with markup = no and markup = strip this happens. I think it's expected for the markup=yes case, and maybe for markup=strip, but I think for markup = no there should be no weird things like this going on.

fwsmit avatar Mar 21 '22 15:03 fwsmit

Turns out, this behaviour is not because of dunst, but because of notify-send and dunstify. They "compress" any c-style escape characters in the body, but not the summary. I'll have to read the specification for why that's the case.

In dunstify's case, it uses g_strcompress instead of g_strdup to copy the body string.

fwsmit avatar May 06 '22 16:05 fwsmit

@bebehei @tsipinakis Do you have a good explanation for why dunstify uses g_strcompress before it sends the body text to dunst. Shouldn't it be done inside of dunst and be dependent on the markup value.?

g_strcompress: https://docs.gtk.org/glib/func.strcompress.html

fwsmit avatar May 06 '22 19:05 fwsmit

I haven't touched dunstify much.

Have you done a git log/blame on it and checked the commit messages?

bebehei avatar May 06 '22 19:05 bebehei

Turns out, this behaviour is not because of dunst, but because of notify-send and dunstify. They "compress" any c-style escape characters in the body, but not the summary. I'll have to read the specification for why that's the case.

The body is usually capable of HTML while the summary is not.

Most of weird behaviors between summary/body, this had been the reason.

Maybe there is some C-Style ambiguity to prohibit control chars, which notification spec does not support.

bebehei avatar May 06 '22 19:05 bebehei

But when markup=no, shouldn't all characters just be shown as is by dunst? Now that's impossible, because they are already filtered by dunstify and notify-send.

fwsmit avatar May 06 '22 20:05 fwsmit

This is still a problem. There's even a warning from g_strcompress

notify-send -t 5000 "test" "\\"

(notify-send:225138): GLib-WARNING **: 17:05:33.662: g_strcompress: trailing \

Can this be fixed ? Is there a way to print a "\" in dunst notification ? I tried to escape it any way I could and it seems like all "\" characters are just removed

EDIT: Lol, even this comment (in markdown i guess ?) requires the backwards slash to be written twice to be displayed once. The only reason I need this in dunst is to display a Windows file path.... so again I blame Microsoft

pseregiet avatar Mar 07 '23 16:03 pseregiet