summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-14 17:45:22 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-02-14 17:45:22 +0000
commit052b7d0ca79f75cd1e9c9d6f5d7eb0a75a0a43ff (patch)
treedee4a2cc9d4e57ff1d9056e1244a37cc1c9cdf68
parentd68898a03381809841da9e930005b3d92fee15f8 (diff)
parent22960c5c20cf5a2d4666645f259d376784a11331 (diff)
downloadgtk+-052b7d0ca79f75cd1e9c9d6f5d7eb0a75a0a43ff.tar.gz
Merge branch 'fix-compose-comments-for-3' into 'gtk-3-24'
imcontext: Fix a regression in Compose file parsing See merge request GNOME/gtk!3200
-rw-r--r--gtk/gtkcomposetable.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c
index 95cb16f9b8..f8657d2660 100644
--- a/gtk/gtkcomposetable.c
+++ b/gtk/gtkcomposetable.c
@@ -77,28 +77,40 @@ parse_compose_value (GtkComposeData *compose_data,
const char *val,
const char *line)
{
- char *word;
const char *p;
- gsize len;
GString *value;
gunichar ch;
char *endp;
- len = strlen (val);
- if (val[0] != '"' || val[len - 1] != '"')
+ if (val[0] != '"')
{
g_warning ("Need to double-quote the value: %s: %s", val, line);
goto fail;
}
- word = g_strndup (val + 1, len - 2);
-
value = g_string_new ("");
- p = word;
+ p = val + 1;
while (*p)
{
- if (*p == '\\')
+ if (*p == '\0')
+ {
+ g_warning ("Missing closing '\"': %s: %s", val, line);
+ goto fail;
+ }
+ else if (*p == '\"')
+ {
+ p++;
+ while (*p && g_ascii_isspace (*p))
+ p++;
+ if (*p != '\0' && *p != '#')
+ {
+ g_warning ("Garbage after closing '\"': %s: %s", val, line);
+ goto fail;
+ }
+ break;
+ }
+ else if (*p == '\\')
{
if (p[1] == '"')
{
@@ -148,8 +160,6 @@ parse_compose_value (GtkComposeData *compose_data,
compose_data->value = g_string_free (value, FALSE);
- g_free (word);
-
return TRUE;
fail: