On 2026-05-29 Paul Eggert wrote:
> I attempted to address the problem by having the USE_C_LOCALE code in 
> Gnulib treat unassigned character positions as printable, in this
> Gnulib patch:
> 
> https://cgit.git.savannah.gnu.org/cgit/gnulib.git/commit/?id=d9723b157578980c0c37782408a89e381393f032

It blocks C0 control chars but not C1. The byte values of C1 controls
depend on terminal's character set, which hopefully is in sync with
LC_CTYPE seen by the applications.

To properly filter malicious use of non-printable chars, I don't see a
way to avoid setlocale(LC_CTYPE, "") and iswprint. Without setlocale,
one either blocks printable non-ASCII chars (clearly not acceptable) or
doesn't filter C1 controls. The latter might be OK if quotearg is wanted
for non-security reasons. If USE_C_LOCALE support is kept in quotearg,
it would be good to add a comment to warn about C1 control chars.

These examples work at least in Konsole and VTE-based terminals:

    $ printf 'foo\u009b3Dbar\n'
    bar

    $ printf 'a\u0090 Can you see me? \u009cb\n'
    ab

    $ printf 'a\u009b31m red \u009b0mb\n'
    a red b

-- 
Lasse Collin



Reply via email to