]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Shell: Reject \u and \U escape sequences that produce surrogates.
authorBruno Haible <bruno@clisp.org>
Sat, 21 Jun 2025 04:49:23 +0000 (06:49 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 21 Jun 2025 04:49:23 +0000 (06:49 +0200)
* gettext-tools/src/x-sh.c (read_word): Reject \u and \U values in the range
0xD800..0xDFFF.
* gettext-tools/tests/xgettext-sh-9: Add more test cases.

gettext-tools/src/x-sh.c
gettext-tools/tests/xgettext-sh-9

index 67ff5730a18d5510999f816d04a951ae122655f2..8156bb7df32a1143e2269d9c28cd7be0b87b5960 100644 (file)
@@ -1090,7 +1090,7 @@ read_word (struct word *wp, int looking_for, flag_region_ty *region)
                                   }
                                 if (j > 0)
                                   {
-                                    if (n < 0x110000)
+                                    if (n < 0x110000 && !(n >= 0xD800 && n <= 0xDFFF))
                                       {
                                         if (wp->type == t_string)
                                           mixed_string_buffer_append_unicode (wp->token, n);
index b62f83803b3f795efd39fe982b47b12d0e7cc1a6..263d183429cbe16dab38c8e53227d7810a3ec306 100755 (executable)
@@ -12,6 +12,9 @@ echo `gettext $'depth_1_dollar_bash_\u20accd\U1f603kl'`
 
 echo `echo \`gettext $'depth_2_dollar_posix_\xc1mn\301op'\``
 echo `echo \`gettext $'depth_2_dollar_bash_\u20accd\U1f603kl'\``
+
+gettext $'high surrogate \udada'
+gettext $'low surrogate \udddd'
 EOF
 
 : ${XGETTEXT=xgettext}
@@ -55,6 +58,12 @@ msgstr ""
 
 msgid "depth_2_dollar_bash_€cd😃kl"
 msgstr ""
+
+msgid "high surrogate \\udada"
+msgstr ""
+
+msgid "low surrogate \\udddd"
+msgstr ""
 EOF
 
 : ${DIFF=diff}