From: Bruno Haible Date: Sat, 21 Jun 2025 04:49:23 +0000 (+0200) Subject: xgettext: Shell: Reject \u and \U escape sequences that produce surrogates. X-Git-Tag: v0.26~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3e7c882bd77ece8d0c1eab91e74d4e9dadac1f56;p=thirdparty%2Fgettext.git xgettext: Shell: Reject \u and \U escape sequences that produce surrogates. * 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. --- diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 67ff5730a..8156bb7df 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -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); diff --git a/gettext-tools/tests/xgettext-sh-9 b/gettext-tools/tests/xgettext-sh-9 index b62f83803..263d18342 100755 --- a/gettext-tools/tests/xgettext-sh-9 +++ b/gettext-tools/tests/xgettext-sh-9 @@ -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}