FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.77k stars 89 forks source link

Single quotes are being escaped in JSON serialization #474

Closed zemzelett closed 9 months ago

zemzelett commented 9 months ago

Hi there,

i was dabbling with my bar config yesterday and noticed some error arising from parsing the JSON output of sketchybar --query with jq:

jq: parse error: Invalid escape at line 124, column 98

This error message came from a value i provided to a click_script property:

click_script="open -a 'System Preferences'"

Changing this to the following made the error disappear:

click_script="open -a \"System Preferences\""

The problem with the first one is, that the apostrophe is being escaped during serialization since the following commit: https://github.com/FelixKratz/SketchyBar/commit/14c6381aa80246d161e6bce410e981190a9a719e

I can't tell, why that has been introduced but the apostrophe is a character that must not be escaped according to RFC 7159 Section 7.

Sadly, jq does not parse the rest of the JSON due to the error being thrown.

Again, i'm not sure what led to the decision of escaping apostrophes but, in my opinion, this should either be fixed by (preferably) reverting the above commit or by adding something to the documentation hinting towards this behavior.

FelixKratz commented 9 months ago

Agreed, reverted commit https://github.com/FelixKratz/SketchyBar/commit/14c6381aa80246d161e6bce410e981190a9a719e and included in v2.19.6