prefs: Preserve UTF-8 characters in preferences.
When saving preferences the strings in string lists must not be escaped with g_strescape() because this will destroy UTF-8 characters. Because this strings only should use printable characters we manually escape quote and backslash, and skip non-printable. Bug: 13342 Change-Id: I57e492dff746a5ecc0aee809f946a615ad110b4d Reviewed-on: https://code.wireshark.org/review/19738 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
87f4dc0a9d
commit
7f4d8491f3
18
epan/prefs.c
18
epan/prefs.c
|
@ -3649,7 +3649,6 @@ char *join_string_list(GList *sl)
|
||||||
GString *joined_str = g_string_new("");
|
GString *joined_str = g_string_new("");
|
||||||
GList *cur, *first;
|
GList *cur, *first;
|
||||||
gchar *str;
|
gchar *str;
|
||||||
gchar *quoted_str;
|
|
||||||
guint item_count = 0;
|
guint item_count = 0;
|
||||||
|
|
||||||
cur = first = g_list_first(sl);
|
cur = first = g_list_first(sl);
|
||||||
|
@ -3666,9 +3665,20 @@ char *join_string_list(GList *sl)
|
||||||
} else
|
} else
|
||||||
g_string_append_c(joined_str, ' ');
|
g_string_append_c(joined_str, ' ');
|
||||||
|
|
||||||
quoted_str = g_strescape(str, "");
|
g_string_append_c(joined_str, '"');
|
||||||
g_string_append_printf(joined_str, "\"%s\"", quoted_str);
|
while (*str) {
|
||||||
g_free(quoted_str);
|
gunichar uc = g_utf8_get_char (str);
|
||||||
|
|
||||||
|
if (uc == '"' || uc == '\\')
|
||||||
|
g_string_append_c(joined_str, '\\');
|
||||||
|
|
||||||
|
if (g_unichar_isprint(uc))
|
||||||
|
g_string_append_unichar (joined_str, uc);
|
||||||
|
|
||||||
|
str = g_utf8_next_char (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append_c(joined_str, '"');
|
||||||
|
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue