summaryrefslogtreecommitdiff
path: root/0001-imcontext-Fix-a-regression-in-Compose-file-parsing.patch
blob: 04614a43cb15b146b4f9bf35a279287c709086f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
From 22960c5c20cf5a2d4666645f259d376784a11331 Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Sun, 14 Feb 2021 11:54:05 -0500
Subject: [PATCH 1/3] imcontext: Fix a regression in Compose file parsing

We accidentally dropped the handing of # comments.
Bring it back.

Fixes: #3664
---
 gtk/gtkcomposetable.c | 30 ++++++++++++++++++++----------
 1 file 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:
-- 
2.29.2

bgstack15