When SSID name contains regular non-alphanumeric characters like &, widget output fails with following error being logged:
(process:183221): Pango-WARNING **: 09:27:14.559: 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 \&\;
It seems output of external commands is not handled properly (ie. escaped) before sent to i3bar.
Affected lines for blocks/net:
https://github.com/greshake/i3status-rust/blob/2efa54c39fa56613ecfe77b34a7cb248bc783de0/src/blocks/net.rs#L170
The quick fix for net would be straightforward, ie. do escaping of returned string but I'd suggest do it in a more general way, like some helper function for safe processing external command calls and their output.
Something like this?

There are errors galore in sway's output but the bar itself appears to be working for me. Or at least it was reacting to the network going up and down. I can only test with a virtual wifi adapter so testing is kinda limited.
Does the bar crash for you?
However this is implemented in our code, these are the chars that have to be escaped:
< to <
> to >
& to &
' to '
@ammgws No, the bar does not crash but SSID string is not displayed and quoted error starts appear in .xsession-errors log.
Tested with two access points, one constituting ID with alphanumeric chars only, the second with ampersand in between (like "Laurel&Hardy"). The issue exists only in the second case.
OK so it doesn't display at all on i3, while it does on sway.
Need to come up with a function that escapes these for us.
Yep, I'm running with i3.
Didn't found where the special characters get escaped in i3status-rust code.
I just realised I came across this error before in another block: https://github.com/greshake/i3status-rust/pull/518.
We don't escape anything at the moment. We need to write a function that escapes those characters listed above and then use it here: https://github.com/greshake/i3status-rust/blob/d6efae28e53d41d9f2909918a03b4223cc42f994/src/widgets/button.rs#L50, and anywhere else that has "markup": "pango".
I'll get around to it in a couple hours
It's fixed for me now. Please re-open if not for you.
It's fixed for me now. Please re-open if not for you.
Works for me. Thanks!
I'm not sure, but I have the impression tha escaping does defeat the purpose of pango markup or did I miss something.
For example, I have the following conf:
[[block]]
block = "time"
interval = 60
format = "%a %d/%m <b>%R</b>"
Before, the hour:minute part of the time widget was displayed as bold, but now I see the markup in the widget.
Shouldn't the escaping only be done for each widget when the user has no control of the data (for example ssid).
Hmm I'm on mobile atm so a bit limited but I suspect it's because you don't have pango set in your i3/swaybar font config. IIRC pango output is enabled for all blocks that use the TextWidget, so it's likely you'd see unformatted pango in other blocks as well (assuming they have text that would get escaped like your time block). If enabling pango in your config isn't an option then will need to think about this...
Sorry I misread your comment. So your pango formatting was actually broken by this. I'll look into this tonight hopefully!
Shouldn't the escaping only be done for each widget when the user has no control of the data (for example ssid).
Indeed. I'll push a fix today or tomorrow.
Thanks !
Seems like this issue hasn't been fully resolved. At least not for custom blocks.
#!/bin/sh
## Fails - Empty
echo "{\"text\":\"1 &\"}"
## Works
echo "{\"text\":\"2 &\"}"
## Fails - Empty
echo "1 &"
## Works
echo "2 &"
## Works
echo "{\"text\":\"1 >\"}"
## Works
echo "{\"text\":\"2 >\"}"
## Works
echo "1 >"
## Works
echo "2 >"
## Fails - Empty
echo "{\"text\":\"1 <\"}"
## Works
echo "{\"text\":\"2 <\"}"
## Fails - Empty
echo "1 <"
## Works
echo "2 <"
## Works
echo "{\"text\":\"1 '\"}"
## Works
echo "{\"text\":\"2 '\"}"
## Works
echo "1 '"
## Works
echo "2 '"