dunst-project / dunst

Lightweight and customizable notification daemon
https://dunst-project.org
Other
4.42k stars 338 forks source link

icon file with two `'` characters in path fail to load #1307

Closed shmibs closed 3 months ago

shmibs commented 4 months ago

Issue description

the commit adding wordexp in string_to_path, https://github.com/dunst-project/dunst/commit/e9a27c057865cae91ea0c7a45602d1ff0a2b9155 , seems to have introduced an error parsing file paths with an even number of 's. i've noticed because of an mpd status script which displays with icons contained in the music directory, hence lots of odd file names and directories

it seems an odd number of ' errors out with WRDE_SYNTAX and returns the string without expansion... which in my case is a success, as the file path is unmodified. when an even number of ' is present though, they're stripped away, returning an invalid file path without them

if there's some effective way to escape these with \ i also haven't figured it out

Installation info

zappolowski commented 4 months ago

How are these paths provided to dunst? Via configuration file or as command line argument? Could you please provide an example usage?

Using e.g. in the configuration:

[urgency_low]
  default_icon = /tmp/' test '/it\'s_complicated

(and putting an icon there) I can get it to work. The same string also works when used on the command line:

dunstify --icon /tmp/' test '/it\'s_complicated Testing
shmibs commented 4 months ago

(that filepath seems to contain only one ' character rather than an even number, so as described it ought to work?

and apologies, un. the same issue is present either through config or cli, e.g.

[urgency_low]
    default_icon = "/tmp/test'/test'/cover-small.png"
dunstify --icon="/tmp/test'/test'/cover-small.png" test

the ' are silently stripped away, so if a filepath without them exists, /test/test/, it will end up using that instead

edit: it seems really the issue here is using wordexp at all, evaluating the same path twice to cause unexpected behaviour like this and potentially others as well

zappolowski commented 4 months ago

Can you give #1314 a try?

I've tested with

[urgency_low]
default_icon = $HOME/tmp/test\'/test\'/urgency_low.svg

[dunstify]
appname = dunstify
new_icon = "$HOME/tmp/test\'/test\'/dunstify.svg"

and then

$ dunstify Testing
$ notify-send --urgency low Testing
$ notify-send --icon "$HOME/tmp/test'/test'/path.svg" Testing

and it always showed the matching icon.

shmibs commented 4 months ago

that seems working, yes ^^