tree_append_json: Allow strings that are not valid UTF8
Fixes #3156. I couldn't reproduce the problem in a "natural" way so I cheated: 1. Start i3 with gdb 2. Set breakpoing on tree_restore 3. Run, open window, i3-msg restart 5. Open the file in *path with a hex editor 6. Edit the "name" field of the window and insert bytes that are not valid UTF8 7. Continue After parsing fails, all nodes including croot are incomplete, meaning they have to be deleted. We can't recover in any reasonable way so we have to allow non-UTF8 characters to avoid this situation altogether.
This commit is contained in:
parent
e8d2b9b7b5
commit
be6faa3161
|
@ -611,6 +611,10 @@ void tree_append_json(Con *con, const char *buf, const size_t len, char **errorm
|
||||||
yajl_config(hand, yajl_allow_comments, true);
|
yajl_config(hand, yajl_allow_comments, true);
|
||||||
/* Allow multiple values, i.e. multiple nodes to attach */
|
/* Allow multiple values, i.e. multiple nodes to attach */
|
||||||
yajl_config(hand, yajl_allow_multiple_values, true);
|
yajl_config(hand, yajl_allow_multiple_values, true);
|
||||||
|
/* Allow strings that are not valid UTF8. Could be possible if a container
|
||||||
|
* name contains such characters. If yajl stops parsing because of this, an
|
||||||
|
* in-place restart could fail: see #3156. */
|
||||||
|
yajl_config(hand, yajl_dont_validate_strings, true);
|
||||||
json_node = con;
|
json_node = con;
|
||||||
to_focus = NULL;
|
to_focus = NULL;
|
||||||
incomplete = 0;
|
incomplete = 0;
|
||||||
|
|
Loading…
Reference in New Issue