[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: \c escape within $'...' can produce mangled UTF-8

From: Andre Majorel
Subject: Re: \c escape within $'...' can produce mangled UTF-8
Date: Sun, 15 Aug 2010 08:24:41 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On 2010-08-15 01:08 +0400, Dmitry Groshev wrote:

> If an escape's parameter makes no sense, escape sequence should be
> left untranslated - just the way "\x" handles things like "\xZZ". Make
> "\c" check that its parameter is an ASCII char, and the problem will
> be fixed.
> Unless for some reason you consider this bug worth preserving. :-)

Guess the code blindly outputs the next char & 0x1f. Which is
a good thing in a way because if it did check that the next char
is between 0x3f and 0x5e, there would be no way to produce
"\x1c" through \c :

$ sh <<\EOF
printf '%s' $'\c\' | xxd
sh: line 1: unexpected EOF while looking for matching `''
sh: line 2: syntax error: unexpected end of file
$ sh <<\EOF
printf '%s' $'\c\\' | xxd
0000000: 1c5c                                     .\

Of course there's $'\x1c' and $'\034' so it's kind of moot.

André Majorel http://www.teaser.fr/~amajorel/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]