compose table parses escaped values incorrectly
Submitted by Roderich Schupp
Link to original bug (#792179)
Description
Created attachment 366254 Proposed patch (against master, but also applies to 3.22.26)
I tried to add some custom compose sequence to my ~/.config/gtk-3.0/Compose, e.g. the line
<Multi_key>
<less>
<minus>
: "\20620" #LEFTWARDS ARROW
but Gtk reports the following error
GTK+ supports to output one char only: "\20620" #LEFTWARDS ARROW: <Multi_key>
<less>
<minus>
: "\20620" #LEFTWARDS ARROW
The parsing is done in parse_compose_value() in gtk/gtkcomposetable.c and it get's it wrong for -escaped (octal) strings: the check
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);
is also applied when the string is escaped (where it is trivially true).
Parsing uses a lot of implicit state (e.g. for the handling of compose_data->comment), is sometimes funny
/* The escaped octal */
else if (uch >= '0' && uch <= '8') <--- '8' in an octal number?
and doesn't cover escaped hexadecimal strings like the original from libX11.
The syntax for the target string in libX11 modules/im/ximcp/imLcPrs.c is:
STRING ::= '"' { CHAR } '"'
CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR
GRAPHIC_CHAR ::= locale (codeset) dependent code
ESCAPED_CHAR ::= ('\\' | '\"' | OCTAL | HEX )
OCTAL ::= '\' OCTAL_CHAR [OCTAL_CHAR [OCTAL_CHAR]]
OCTAL_CHAR ::= (0|1|2|3|4|5|6|7)
HEX ::= '\' (x|X) HEX_CHAR [HEX_CHAR]]
HEX_CHAR ::= (0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|a|b|c|d|e|f)
Patch attached that fixes the original problem and parses escaped hexadecimal strings, too. The problem is still present in Git master.
Of course, the suggestion in #773919 would be even better.
Patch 366254, "Proposed patch (against master, but also applies to 3.22.26)":
compose.patch
Version: 3.22.x