all: consider all ASCII spaces for _nm_utils_escape_spaces() and unescape

This commit is contained in:
Thomas Haller 2019-03-20 12:17:38 +01:00
parent 5b8305c27c
commit e26e0fdffd

View file

@ -2422,8 +2422,6 @@ _nm_utils_user_data_unpack (gpointer user_data, int nargs, ...)
/*****************************************************************************/
#define IS_SPACE(c) NM_IN_SET ((c), ' ', '\t')
const char *
_nm_utils_escape_spaces (const char *str, char **to_free)
{
@ -2438,7 +2436,7 @@ _nm_utils_escape_spaces (const char *str, char **to_free)
while (TRUE) {
if (!*ptr)
return str;
if (IS_SPACE (*ptr))
if (g_ascii_isspace (*ptr))
break;
ptr++;
}
@ -2448,7 +2446,7 @@ _nm_utils_escape_spaces (const char *str, char **to_free)
r = ret;
*to_free = ret;
while (*ptr) {
if (IS_SPACE (*ptr))
if (g_ascii_isspace (*ptr))
*r++ = '\\';
*r++ = *ptr++;
}
@ -2468,13 +2466,13 @@ _nm_utils_unescape_spaces (char *str, gboolean do_strip)
return NULL;
if (do_strip) {
while (str[i] && IS_SPACE (str[i]))
while (str[i] && g_ascii_isspace (str[i]))
i++;
}
for (; str[i]; i++) {
if ( str[i] == '\\'
&& IS_SPACE (str[i+1])) {
&& g_ascii_isspace (str[i+1])) {
preserve_space_at = j;
i++;
}
@ -2484,15 +2482,13 @@ _nm_utils_unescape_spaces (char *str, gboolean do_strip)
if (do_strip && j > 0) {
while ( --j > preserve_space_at
&& IS_SPACE (str[j]))
&& g_ascii_isspace (str[j]))
str[j] = '\0';
}
return str;
}
#undef IS_SPACE
/*****************************************************************************/
typedef struct {