Properly print arbitrary strings as valid JSON. #1362
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
..instead of injecting them in the output between a pair of '"' charcters.
This prevents windows with a
"
character in their class or instance name (e.g.urxvt -name 'quote "'
), or desktop and monitors with"
character in their name from generating invalid or "malicious" JSON.The main problems that this was causing were:
JSON tools like
jq
were not able to parse the JSON output of "query -T" and "wm -d";if the JSON was invalid (e.g. one extra quote or
\
at the end of desktop name), bspwm would not adopt orphans after a "wm -r" command.if the arbitrary strings contained JSON code: e.g.
bspc desktop -n '","name":"hello'
the JSON will be interpreted by bspwm after a reload. (in the example above, that desktop will be renamed to "hello" after a reload.)