tobi-wan-kenobi / bumblebee-status

bumblebee-status is a modular, theme-able status line generator for the i3 window manager.
https://bumblebee-status.readthedocs.io/en/main/
MIT License
1.23k stars 229 forks source link

'&' not displayed if it's not escaped and --markup=pango is used #507

Closed ghost closed 4 years ago

ghost commented 4 years ago

Bug Report

Summary

Affected module: many

Description:

The pango markup specification requires to escape the '&' char as '\&' . If it's not happening, a warning is displayed:

(process:3000): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as &

Probably bumblebee shouldn't blindly escape everything, because certain users may know about it and pass already escaped data as parameters.

Yet, it's a good idea to improve the help message for --markup option and explicitly warn the user about the need to escape '&' in parameters and in output produced by custom scripts used by shell.command.

And of course, plugins that display filenames/metadata (like mpd, cmus, etc) will have to be patched so they escape '&' if --markup=pango is used.

How to reproduce

Here is a simple example:

status_command python3 ~/bumblebee-status/bumblebee-status -m spacer:spacer1 spacer:spacer2 -p spacer1.text="wrong: &" spacer2.text="right: &" --markup=pango -t gruvbox-powerline

Another example: try playing an audio file that has '&' in the file name (because this is a legit symbol in file names) and use one of the {file} tags in mpd.format and --markup=pango - bumblebee won't display anything as well, just the buttons - this is how I initially spotted the bug.

tobi-wan-kenobi commented 4 years ago

Hm, good catch!

I am leaning towards doing the escaping in the output module and expecting modules to not escape. Having a mix and match invites strange errors, I believe.

How would that sound to you? The fix would be fairly trivial, I think (will commit it, we can always change it later)

ghost commented 4 years ago

Hopefully there's nothing wrong with this approach: since the addition of pango markup support is pretty new, there shouldn't be too many third party setups that will end broken due to double escaping.