From f757c4a5122776d8af11d432f065cd54049eec3e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 15 Nov 2021 15:56:11 +0100 Subject: [PATCH] syntaxes: colorize hex more strictly by using character class [:xdigit:] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In UTF-8 locales, the ranges A-F and a-f include several accented characters beyond "ABCDEF" and "abcdef", such as the Croat č and ć. This fixes https://savannah.gnu.org/bugs/?61487. Bug existed since the beginning of each of the syntaxes, for the C syntax since version 1.3.6, commit 159bdfdc. --- syntax/c.nanorc | 2 +- syntax/go.nanorc | 2 +- syntax/javascript.nanorc | 2 +- syntax/json.nanorc | 4 ++-- syntax/lua.nanorc | 2 +- syntax/objc.nanorc | 2 +- syntax/po.nanorc | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/syntax/c.nanorc b/syntax/c.nanorc index 23923526..6f23cc6a 100644 --- a/syntax/c.nanorc +++ b/syntax/c.nanorc @@ -23,7 +23,7 @@ color brightyellow "\<(try|throw|catch|operator|new|delete)\>" color magenta "\<(break|continue|goto|return)\>" # Single-quoted stuff (characters, backslash escapes, hex and octal byte codes). -color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'" +color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'" # GCC builtins. color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" diff --git a/syntax/go.nanorc b/syntax/go.nanorc index 00b4e6ec..9e5df722 100644 --- a/syntax/go.nanorc +++ b/syntax/go.nanorc @@ -27,7 +27,7 @@ color brightcyan "\<(package|import)\>" # Literals. color red "\<(true|false|nil|iota|_)\>" -color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>" +color red "\<([1-9][0-9]*|0[0-7]*|0[xX][[:xdigit:]]+)\>" color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>" color red "\<[0-9]+[eE][+-]?[0-9]+i?\>" color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>" diff --git a/syntax/javascript.nanorc b/syntax/javascript.nanorc index 4b161cad..1132daca 100644 --- a/syntax/javascript.nanorc +++ b/syntax/javascript.nanorc @@ -12,7 +12,7 @@ color brightyellow "\<(await|export|import|throw|try|catch|finally|new|delete)\> color magenta "\<(break|continue|return|yield)\>" # Octal/decimal and hexadecimal numbers. -color cyan "\<([0-9]+|0x[0-9A-Fa-f]+)\>" +color cyan "\<([0-9]+|0x[[:xdigit:]]+)\>" # Special values. color cyan "\<(true|false|null|undefined)\>" diff --git a/syntax/json.nanorc b/syntax/json.nanorc index 9178f1e3..3dacb3e9 100644 --- a/syntax/json.nanorc +++ b/syntax/json.nanorc @@ -12,9 +12,9 @@ color green ":[[:blank:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?" # Values (well, any string). color brightmagenta "".+"" # Hex numbers (used as value). -color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+"" +color green ":[[:blank:]]*"#[[:xdigit:]]+"" # Escapes. -color green "\\["\/bfnrt]" "\\u[0-9abcdefABCDEF]{4}" +color green "\\(["\/bfnrt]|u[[:xdigit:]]{4})" # Special words. color green "\<(true|false|null)\>" diff --git a/syntax/lua.nanorc b/syntax/lua.nanorc index f12c38a9..00fab57d 100644 --- a/syntax/lua.nanorc +++ b/syntax/lua.nanorc @@ -45,7 +45,7 @@ color brightmagenta "\<(false|nil|true)\>" # Decimal and hexadecimal numbers color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>" -color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>" +color red "\<0x[[:xdigit:]]+(\.[[:xdigit:]]*)?([Pp][+-]?[0-9]+)?\>" # Brackets color brightmagenta "\(|\)|\[|\]|\{|\}" diff --git a/syntax/objc.nanorc b/syntax/objc.nanorc index 97940b80..31e172be 100644 --- a/syntax/objc.nanorc +++ b/syntax/objc.nanorc @@ -24,7 +24,7 @@ color magenta "[[:alnum:]]*:" color white "\[[^][:blank:]]*\]" # Strings. -color brightblack "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'" +color brightblack "'([^'\]|\\(["'\abfnrtv]|x[[:xdigit:]]{1,2}|[0-3]?[0-7]{1,2}))'" color brightblack "<[^= ]*>|"([^"\]|\\.)*"" color brightblue "@"([^"\]|\\.)*"" diff --git a/syntax/po.nanorc b/syntax/po.nanorc index 5c1746d3..789379ba 100644 --- a/syntax/po.nanorc +++ b/syntax/po.nanorc @@ -25,7 +25,7 @@ color yellow " (no-)?[-[:alpha:]]+-format(,|$)" color brightmagenta "%([1-9]\$)?[#0 +'I-]?(\*([1-9]\$)?|[1-9](\.[0-9]?)?)?[hlLjzt]?[diouxXeEfFgGaAcspnm%]" # Quotes and escaped characters. color yellow """ -color cyan "\\([abcefnrtv"\]|x[0-9abcdefABCDEF]{2}|[0-7]{3})" +color cyan "\\([abcefnrtv"\]|x[[:xdigit:]]{2}|[0-7]{3})" # Reminders. color brightwhite,yellow "\<(FIXME|TODO|XXX)\>" # Obsolete strings.