LemonBoy / bar

A featherweight, lemon-scented, bar based on xcb
MIT License
1.61k stars 194 forks source link

Double percent sign does not escape formatting commands #200

Closed ntrrgc closed 7 years ago

ntrrgc commented 7 years ago

From the documentation:

lemonbar provides a screenrc-inspired formatting syntax to allow full customization at runtime. Every formatting block is opened with %{ and closed by } and accepts the following commands, the parser tries it's best to handle malformed input. Use %% to get a literal percent sign (%).

Indeed, %% produces a single visible %, as expected... but unfortuantely, it still renders any command in braces after that!

For instance, imagine we are showing the window title in bar, which currently is this:

What is %{REQUEST_URI} in .htaccess? - Google Chrome

That %{ is doomed to be interpreted by bar as a formatting command, let's escape it properly!

What is %%{REQUEST_URI} in .htaccess? - Google Chrome

But instead of being escaped correctly, this is what happens:

Which is quite wierd, as if the %% token was consumed twice, once for producing the % symbol and another time for rendering the { as a command (which I tried to avoid).

As a workaround, I've found Unicode zero-width space works (e.g. "%\uFEFF{REQUEST_URI}").

LemonBoy commented 7 years ago

Good catch, the latest commit fixes this problem.

ntrrgc commented 7 years ago

That was fast, thank you!