LemonBoy/bar

Double percent sign does not escape formatting commands

ntrrgc opened this issue · 2 comments

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}").

Good catch, the latest commit fixes this problem.

That was fast, thank you!