Commit a6c57591 authored by Allison Karlitskaya's avatar Allison Karlitskaya

Support &s as key of dict entry in format string

Partial fix for bug 613618.
parent 816990a0
...@@ -2745,15 +2745,25 @@ g_variant_format_string_scan (const gchar *string, ...@@ -2745,15 +2745,25 @@ g_variant_format_string_scan (const gchar *string,
case '{': case '{':
c = next_char(); c = next_char();
if (c == '@') if (c == '&')
c = next_char (); {
c = next_char ();
/* ISO/IEC 9899:1999 (C99) §7.21.5.2: if (c != 's' && c != 'o' && c != 'g')
* The terminating null character is considered to be return FALSE;
* part of the string. }
*/ else
if (c != '\0' && strchr ("bynqiuxthdsog?", c) == NULL) {
return FALSE; if (c == '@')
c = next_char ();
/* ISO/IEC 9899:1999 (C99) §7.21.5.2:
* The terminating null character is considered to be
* part of the string.
*/
if (c != '\0' && strchr ("bynqiuxthdsog?", c) == NULL)
return FALSE;
}
if (!g_variant_format_string_scan (string, limit, &string)) if (!g_variant_format_string_scan (string, limit, &string))
return FALSE; return FALSE;
......
...@@ -2699,6 +2699,13 @@ test_format_strings (void) ...@@ -2699,6 +2699,13 @@ test_format_strings (void)
*end == '\0'); *end == '\0');
g_assert (g_variant_format_string_scan ("{yv}", NULL, &end) && g_assert (g_variant_format_string_scan ("{yv}", NULL, &end) &&
*end == '\0'); *end == '\0');
g_assert (!g_variant_format_string_scan ("{&?v}", NULL, &end));
g_assert (g_variant_format_string_scan ("{@?v}", NULL, &end) &&
*end == '\0');
g_assert (!g_variant_format_string_scan ("{&@sv}", NULL, &end));
g_assert (!g_variant_format_string_scan ("{@&sv}", NULL, &end));
g_assert (g_variant_format_string_scan ("{&sv}", NULL, &end) &&
*end == '\0');
g_assert (!g_variant_format_string_scan ("{vv}", NULL, &end)); g_assert (!g_variant_format_string_scan ("{vv}", NULL, &end));
g_assert (!g_variant_format_string_scan ("{y}", NULL, &end)); g_assert (!g_variant_format_string_scan ("{y}", NULL, &end));
g_assert (!g_variant_format_string_scan ("{yyy}", NULL, &end)); g_assert (!g_variant_format_string_scan ("{yyy}", NULL, &end));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment