summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-01 15:48:43 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-02-01 16:05:05 -0500
commitdbbcb13721c5415d0097612d89c1c9cad0ad0497 (patch)
tree6ac44ff0ddd77bfe8d8b0d4f9113b9bab8d724bf
parentedeaf9c040cf57caa8c8d7de43ffe30555230585 (diff)
downloadgtk+-dbbcb13721c5415d0097612d89c1c9cad0ad0497.tar.gz
composetable: Parser fixes
We were not handling octal escapes right.
-rw-r--r--gtk/gtkcomposetable.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c
index afcedc42df..2b1d7bee7f 100644
--- a/gtk/gtkcomposetable.c
+++ b/gtk/gtkcomposetable.c
@@ -82,6 +82,7 @@ parse_compose_value (GtkComposeData *compose_data,
{
char **words = g_strsplit (val, "\"", 3);
gunichar uch;
+ char *endp;
if (g_strv_length (words) < 3)
{
@@ -102,21 +103,32 @@ parse_compose_value (GtkComposeData *compose_data,
/* The escaped string "\"" is separated with '\\' and '"'. */
if (uch == '\0' && words[2][0] == '"')
- uch = '"';
+ {
+ uch = '"';
+ }
/* The escaped octal */
else if (uch >= '0' && uch < '8')
- uch = g_ascii_strtoll (words[1] + 1, NULL, 8);
+ {
+ uch = g_ascii_strtoll (words[1] + 1, &endp, 8);
+ if (*endp != '\0')
+ {
+ g_warning ("GTK supports to output one char only: %s: %s", val, line);
+ goto fail;
+ }
+ }
/* If we need to handle other escape sequences. */
else if (uch != '\\')
{
g_warning ("Invalid escape sequence: %s: %s", val, line);
}
}
-
- if (g_utf8_get_char (g_utf8_next_char (words[1])) > 0)
+ else
{
- g_warning ("GTK supports to output one char only: %s: %s", val, line);
- goto fail;
+ if (g_utf8_get_char (g_utf8_next_char (words[1])) > 0)
+ {
+ g_warning ("GTK supports to output one char only: %s: %s", val, line);
+ goto fail;
+ }
}
compose_data->value[1] = uch;