State key fix
The characters
, =
, [
, ]
might not always be valid to use in a GKeyFile
key string. For example, the following strings are valid keys:
"foo[bar]"
"foo=bar"
However, these are NOT valid keys:
"foo[bar"
"foo [bar]"
"foo[bar ]"
"foo = bar"
The full logic to determine if a key string is valid is defined in the private g_key_file_is_key_name()
function from glib: https://gitlab.gnome.org/GNOME/glib/blob/2.66.2/glib/gkeyfile.c#L4148
Since those 4 characters are special, this MR escapes them before saving the key in the file, and then compresses the escaped key before finishing loading the file. The special characters will never be stored in the actual file and any string will be accepted as a GKeyFile
.
The escape process converts the special characters in the following valid GKeyFile
key characters:
-
\s
-
=
->\e
-
[
->\o
-
]
->\c
For example, the invalid key foo [bar]
will be store as foo\s\obar\c
in the file.
Fixes #41 (closed)