mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-10 03:10:39 +01:00
ifcfg-rh: fix svEscape() to properly handle double quoting
'\'', '~': must not be escaped with backslash. Also, within double quotes the backslash escape character is only removed before special caracters like '$' or '`'. Not in general. Yes, it means that older versions of svEscape produced invalid escape sequences that we now treat differently. But that is not realy avoidable, it was a bug that needs to be fixed.
This commit is contained in:
parent
337fc582b2
commit
d8c465a3cd
2 changed files with 22 additions and 7 deletions
|
|
@ -174,8 +174,8 @@ _escape_ansic (const char *source)
|
|||
|
||||
#define _char_in_strset(ch, str) (!!strchr (""str"", (ch)))
|
||||
|
||||
#define ESC_ESCAPEES "\"'\\$~`" /* must be escaped */
|
||||
#define ESC_SPACES " \t|&;()<>" /* only require "" */
|
||||
#define ESC_ESCAPEES "\"\\$`" /* must be escaped */
|
||||
#define ESC_SPACES " '\t~|&;()<>" /* only require "" */
|
||||
|
||||
const char *
|
||||
svEscape (const char *s, char **to_free)
|
||||
|
|
@ -385,11 +385,8 @@ svUnescape (const char *value, char **to_free)
|
|||
/* we don't support line continuation */
|
||||
goto out_error;
|
||||
}
|
||||
if (!NM_IN_SET (value[i], '$', '`', '"', '\\')) {
|
||||
/* TODO: svEscape() is not yet ready to handle properly treating
|
||||
* double quotes. */
|
||||
//g_string_append_c (str, '\\');
|
||||
}
|
||||
if (!NM_IN_SET (value[i], '$', '`', '"', '\\'))
|
||||
g_string_append_c (str, '\\');
|
||||
}
|
||||
g_string_append_c (str, value[i]);
|
||||
i++;
|
||||
|
|
|
|||
|
|
@ -8813,6 +8813,24 @@ test_svUnescape (void)
|
|||
V0 ("\t #a", ""),
|
||||
V0 ("\t #a\r", ""),
|
||||
V0 ("\r", ""),
|
||||
V1 ("\\\"", "\""),
|
||||
V1 ("\\`", "`"),
|
||||
V1 ("\\$", "$"),
|
||||
V1 ("\\\\", "\\"),
|
||||
V1 ("\\a", "a"),
|
||||
V1 ("\\b", "b"),
|
||||
V1 ("\\'", "'"),
|
||||
V1 ("\\~", "~"),
|
||||
V1 ("\\\t", "\t"),
|
||||
V1 ("\"\\\"\"", "\""),
|
||||
V1 ("\"\\`\"", "`"),
|
||||
V1 ("\"\\$\"", "$"),
|
||||
V1 ("\"\\\\\"", "\\"),
|
||||
V1 ("\"\\a\"", "\\a"),
|
||||
V1 ("\"\\b\"", "\\b"),
|
||||
V1 ("\"\\'\"", "\\'"),
|
||||
V1 ("\"\\~\"", "\\~"),
|
||||
V1 ("\"\\\t\"", "\\\t"),
|
||||
V0 ("ab\r", "ab"),
|
||||
V0 ("a'b'\r ", "ab"),
|
||||
V0 ("a'b' \r", "ab"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue