GNU bug report logs - #29832
ls: bug in 'ls -FQ': incorrectly quoted characters

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: hackerb9@HIDDEN; dated Sun, 24 Dec 2017 07:15:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Changed bug title to 'ls: bug in 'ls -FQ': incorrectly quoted characters' from 'Bug in 'ls -FQ': incorrectly quoted characters' Request was from Assaf Gordon <assafgordon@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 29832 <at> debbugs.gnu.org:


Received: (at 29832) by debbugs.gnu.org; 24 Dec 2017 12:26:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 24 07:26:34 2017
Received: from localhost ([127.0.0.1]:50143 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eT5MQ-0002EW-Gy
	for submit <at> debbugs.gnu.org; Sun, 24 Dec 2017 07:26:34 -0500
Received: from mail.magicbluesmoke.com ([82.195.144.49]:44538)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <P@HIDDEN>) id 1eT5MO-0002EO-Lz
 for 29832 <at> debbugs.gnu.org; Sun, 24 Dec 2017 07:26:33 -0500
Received: from localhost.localdomain (unknown [109.79.105.77])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 478B8998D;
 Sun, 24 Dec 2017 12:26:31 +0000 (GMT)
Subject: Re: bug#29832: Bug in 'ls -FQ': incorrectly quoted characters
To: hackerb9@HIDDEN, 29832 <at> debbugs.gnu.org
References: <CAO+cPoMAHZfLthJa55aq2OQjhyPFgZ+bG5ERaA_Q=GsK06wiMw@HIDDEN>
From: =?UTF-8?Q?P=c3=a1draig_Brady?= <P@HIDDEN>
Message-ID: <642746a6-f1e1-5546-159f-4c84342677b5@HIDDEN>
Date: Sun, 24 Dec 2017 12:26:30 +0000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <CAO+cPoMAHZfLthJa55aq2OQjhyPFgZ+bG5ERaA_Q=GsK06wiMw@HIDDEN>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 29832
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On 24/12/17 07:14, hackerb9@HIDDEN wrote:
> Hello!
> 
> Thank you for your continued improvements and maintenance of 'ls' in
> coreutils-8.28.
> 
> I have found a somewhat subtle bug. I've included a patch and a test script
> to make sure there are no regressions.
> 
> In short, the problem is that a backlash is incorrectly put in front of the
> characters @, =, >, and |. This only happens when using filetype indicators
> and C style quoting.
> 
>   $ touch @
>   $ ls
>   @
>   $ ls -F
>   @
>   $ ls -Q
>   "@"
>   $ ls -FQ
>   "\@"        # <-- incorrect
> 
> There should be no backslash before the @.
> 
> This was a little bit tricky to track down as the code responsible is not
> commented and appears to have been prematurely optimized by the programmer:
> 
>   ls.c:2141
>   if (file_type <= indicator_style)
>     {
>       char const *p;
>       for (p = &"*=>@|"[indicator_style - file_type]; *p; p++)
>         set_char_quoting (filename_quoting_options, *p, 1);
>     }
> 
> Basically, it says, if --file-type was used, then we should be sure to
> quote '=', '>', and '@'. If --classify is used, then we should do the same
> but also add in '*'. Or, to put it in less compressed C:
> 
>   if (indicator_style == file_type)
>     {
>       char const *p;
>       for (p = "=>@|"; *p; p++)
>         set_char_quoting (filename_quoting_options, *p, 1);
>     }
>   if (indicator_style == classify)
>     {
>       char const *p;
>       for (p = "*=>@|"; *p; p++)
>         set_char_quoting (filename_quoting_options, *p, 1);
>     }
> 
> However, there is no need to quote those characters when the quoting-style
> is set to C. In fact, it is an error to do so as these are not valid C
> escape sequences.
> 
> I am guessing the idea of the code was that those characters would not be
> backslash escaped, but rather the entire filename would be wrapped in
> quotes so the indicator character cannot be confused for part of the
> filename. And, indeed, this does work for some of the quoting styles:
> "shell[-escape][-always]" work that way. Strangely, "c-maybe" also works
> that way.
> 
>   $ ls -F --quoting-style=literal
>   @
>   $ ls -F --quoting-style=shell
>   '@'
>   $ ls -F --quoting-style=shell-always
>   '@'
>   $ ls -F --quoting-style=shell-escape
>   '@'
>   $ ls -F --quoting-style=shell-escape-always
>   '@'
>   $ ls -F --quoting-style=c-maybe
>   "@"        # <-- This is correct!
> 
> I spent some time debugging it, but I didn't find the perfect fix as I
> don't understand why it was written the way it was. Rather, I found
> something that I think is an improvement and a step towards doing things
> right. I've made a patch that simply checks if the quoting style is C and
> skips the problematic lines. Ideally, somebody who understands why this
> code was written this way in the first place can make a better patch, but
> this should work for now and not break anything for anybody else.
> 
> Please find attached below, my patch for src/ls.c and a regression test
> script to be placed in tests/ls/quoting-style-c.sh.
> 
> --b9
> 
> P.S. This bug may also apply to the -b (--quoting-style=escape). However,
> the output from it appears to be more like a mish-mash of C and shell
> escapes. (For example, tabs are shown as "\t", as in C, but spaces are
> shown as "\ ", as in bourne shell. ) The -Q option, on the other hand,
> generates perfectly acceptable C strings (tested with gcc and python),
> except for those few buggy characters fixed in this patch.

Thanks for the detailed analysis.

c-maybe is correct here as quotearg explicitly ignores these extra chars
to be quoted when outer quotes are added.  Therefore we should
probably ignore these extra chars to be quoted when we're adding
outer quotes unconditionally.

This gnulib patch would handle this specific case.
I'll look into generalizing for all outer quoted cases:

diff --git a/lib/quotearg.c b/lib/quotearg.c
index 8e432e1..47ffc5c 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -709,7 +709,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
           }
         }

-      if (! (((backslash_escapes && quoting_style != shell_always_quoting_style)
+      if (! (((backslash_escapes
+               && quoting_style != shell_always_quoting_style
+               && quoting_style != c_quoting_style)
               || elide_outer_quotes)
              && quote_these_too
              && quote_these_too[c / INT_BITS] >> (c % INT_BITS) & 1)

cheers,
Pádraig




Information forwarded to bug-coreutils@HIDDEN:
bug#29832; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Dec 2017 07:14:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 24 02:14:43 2017
Received: from localhost ([127.0.0.1]:49883 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eT0Ud-0002yl-9w
	for submit <at> debbugs.gnu.org; Sun, 24 Dec 2017 02:14:43 -0500
Received: from eggs.gnu.org ([208.118.235.92]:59884)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <benjamin.a.wong@HIDDEN>) id 1eT0Ub-0002yO-BG
 for submit <at> debbugs.gnu.org; Sun, 24 Dec 2017 02:14:41 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <benjamin.a.wong@HIDDEN>) id 1eT0UU-00053F-ED
 for submit <at> debbugs.gnu.org; Sun, 24 Dec 2017 02:14:36 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 HTML_MESSAGE,HTML_NONELEMENT_30_40,T_DKIM_INVALID autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:60966)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <benjamin.a.wong@HIDDEN>)
 id 1eT0UU-000533-8S
 for submit <at> debbugs.gnu.org; Sun, 24 Dec 2017 02:14:34 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50809)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <benjamin.a.wong@HIDDEN>) id 1eT0US-0006DT-J8
 for bug-coreutils@HIDDEN; Sun, 24 Dec 2017 02:14:34 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <benjamin.a.wong@HIDDEN>) id 1eT0UR-00051Z-3M
 for bug-coreutils@HIDDEN; Sun, 24 Dec 2017 02:14:32 -0500
Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]:47026)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <benjamin.a.wong@HIDDEN>)
 id 1eT0UQ-00050W-P9
 for bug-coreutils@HIDDEN; Sun, 24 Dec 2017 02:14:31 -0500
Received: by mail-qk0-x230.google.com with SMTP id b132so9109714qkc.13
 for <bug-coreutils@HIDDEN>; Sat, 23 Dec 2017 23:14:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:sender:from:date:message-id:subject:to;
 bh=Snhc8SVEyvwWx/F0zUgmWpfAeSgca16vFi/unqvlrsA=;
 b=BWFEfhVVmEAu9fIPBzsWtfSw9zoB0WeahKjfxuFPI+t46VtHnQowk30qLyJN6JxkxF
 wi+Ajvdkth/kpKtke3g5XQkL53aN6rZAlLalRlq9zahz+s9r/a/C1m4WTkAjORciXg85
 tgxhf1d8C1CS4ULZ+toVjUoVbJsZOvOUlPYsvozw8NEBFv8CCX1gRg/y7Ep1AqcaVdxv
 7vRZ9TvYjh8loYWi1y7ztOrSbeQcvwpBtUHDsPcTLyR0rDyrb+9X2AfF//RygvuNesq+
 Q2+sODRwFrjUMexyyLjI3xwqmcXWUhIn1eAaL9arq93qihXZgYOxi9d+qidwBNsZXAgi
 huXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:sender:from:date:message-id:subject
 :to; bh=Snhc8SVEyvwWx/F0zUgmWpfAeSgca16vFi/unqvlrsA=;
 b=A7WYTbiK6WC3elks4xbaCLygDj4v0T4wJZoWOpg7CDFk0MTjs0lLOJxm/jk5zbFUSb
 hhOaJq2k5V6U0OX9VdVCuVV3lYC5HbktD4vgk1TiwLGN4xp0nUm26gi4FEhySgwoBvg9
 3LVux2YNMuzRM4knvNHYQbUJCgAie79l/oHGSobUq/ssxQypp2nZqh/5QF1pMCkcBB9M
 rodJgQYNKTOWdSqiJO9lS7JdvDQ7lFo57gCNHXwPsFjdjg4u1KP+CoYaAwLprtnbQsNc
 JPktxCiVTFt4Iw9FuEvQJrBOGWUFEdpUbFnPEr1yZ8/VbTRpBzohi73i4mAn1kJ5vEgx
 A4MQ==
X-Gm-Message-State: AKGB3mIqgGQX2RT6YE36ybwEKeD9AL4wEl0PkMP6GlkRlznUD5d5v7EY
 ivmfuTTUMv7uEoQ063MLD20ybc9T1QgPq/T9bA==
X-Google-Smtp-Source: ACJfBouuu3lXRd9vpgix2ydnhstpl9jKTUKUfOTUmSF57PupuC7YTbEHJajZ3sezdq4Li8M2j4mvR0aRcUP5VacCzYY=
X-Received: by 10.55.17.211 with SMTP id 80mr23814546qkr.120.1514099669396;
 Sat, 23 Dec 2017 23:14:29 -0800 (PST)
MIME-Version: 1.0
Received: by 10.140.39.42 with HTTP; Sat, 23 Dec 2017 23:14:28 -0800 (PST)
From: hackerb9@HIDDEN
Date: Sat, 23 Dec 2017 23:14:28 -0800
X-Google-Sender-Auth: c288CBf2g6bpHkuJWo-huoG9cSY
Message-ID: <CAO+cPoMAHZfLthJa55aq2OQjhyPFgZ+bG5ERaA_Q=GsK06wiMw@HIDDEN>
Subject: Bug in 'ls -FQ': incorrectly quoted characters
To: bug-coreutils@HIDDEN
Content-Type: multipart/mixed; boundary="001a113ac54cf31658056110cc39"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.5 (---)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.5 (---)

--001a113ac54cf31658056110cc39
Content-Type: multipart/alternative; boundary="001a113ac54cf31655056110cc37"

--001a113ac54cf31655056110cc37
Content-Type: text/plain; charset="UTF-8"

Hello!

Thank you for your continued improvements and maintenance of 'ls' in
coreutils-8.28.

I have found a somewhat subtle bug. I've included a patch and a test script
to make sure there are no regressions.

In short, the problem is that a backlash is incorrectly put in front of the
characters @, =, >, and |. This only happens when using filetype indicators
and C style quoting.

  $ touch @
  $ ls
  @
  $ ls -F
  @
  $ ls -Q
  "@"
  $ ls -FQ
  "\@"        # <-- incorrect

There should be no backslash before the @.

This was a little bit tricky to track down as the code responsible is not
commented and appears to have been prematurely optimized by the programmer:

  ls.c:2141
  if (file_type <= indicator_style)
    {
      char const *p;
      for (p = &"*=>@|"[indicator_style - file_type]; *p; p++)
        set_char_quoting (filename_quoting_options, *p, 1);
    }

Basically, it says, if --file-type was used, then we should be sure to
quote '=', '>', and '@'. If --classify is used, then we should do the same
but also add in '*'. Or, to put it in less compressed C:

  if (indicator_style == file_type)
    {
      char const *p;
      for (p = "=>@|"; *p; p++)
        set_char_quoting (filename_quoting_options, *p, 1);
    }
  if (indicator_style == classify)
    {
      char const *p;
      for (p = "*=>@|"; *p; p++)
        set_char_quoting (filename_quoting_options, *p, 1);
    }

However, there is no need to quote those characters when the quoting-style
is set to C. In fact, it is an error to do so as these are not valid C
escape sequences.

I am guessing the idea of the code was that those characters would not be
backslash escaped, but rather the entire filename would be wrapped in
quotes so the indicator character cannot be confused for part of the
filename. And, indeed, this does work for some of the quoting styles:
"shell[-escape][-always]" work that way. Strangely, "c-maybe" also works
that way.

  $ ls -F --quoting-style=literal
  @
  $ ls -F --quoting-style=shell
  '@'
  $ ls -F --quoting-style=shell-always
  '@'
  $ ls -F --quoting-style=shell-escape
  '@'
  $ ls -F --quoting-style=shell-escape-always
  '@'
  $ ls -F --quoting-style=c-maybe
  "@"        # <-- This is correct!

I spent some time debugging it, but I didn't find the perfect fix as I
don't understand why it was written the way it was. Rather, I found
something that I think is an improvement and a step towards doing things
right. I've made a patch that simply checks if the quoting style is C and
skips the problematic lines. Ideally, somebody who understands why this
code was written this way in the first place can make a better patch, but
this should work for now and not break anything for anybody else.

Please find attached below, my patch for src/ls.c and a regression test
script to be placed in tests/ls/quoting-style-c.sh.

--b9

P.S. This bug may also apply to the -b (--quoting-style=escape). However,
the output from it appears to be more like a mish-mash of C and shell
escapes. (For example, tabs are shown as "\t", as in C, but spaces are
shown as "\ ", as in bourne shell. ) The -Q option, on the other hand,
generates perfectly acceptable C strings (tested with gcc and python),
except for those few buggy characters fixed in this patch.

--001a113ac54cf31655056110cc37
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div><div>Hello!<br><br></div>Thank yo=
u for your continued improvements and maintenance of &#39;ls&#39; in coreut=
ils-8.28.<br><br></div>I have found a somewhat subtle bug. I&#39;ve include=
d a patch and a test script to make sure there are no regressions.<br><br><=
/div>In short, the problem is that a backlash is incorrectly put in front o=
f the characters @, =3D, &gt;, and |. This only happens when using filetype=
 indicators and C style quoting.<br><br>=C2=A0 $ touch @<br>=C2=A0 $ ls <br=
>=C2=A0 @<br>=C2=A0 $ ls -F<br>=C2=A0 @<br>=C2=A0 $ ls -Q<br>=C2=A0 &quot;@=
&quot;<br>=C2=A0 $ ls -FQ<br></div><div>=C2=A0 &quot;\@&quot;=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # &lt;-- incorrect<br><br></div>There should=
 be no backslash before the @. <br><br>This was a little bit tricky to trac=
k down as the code responsible is not commented and appears to have been pr=
ematurely optimized by the programmer:<br><br></div>=C2=A0 ls.c:2141<br>=C2=
=A0 if (file_type &lt;=3D indicator_style)<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 char const *p;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 for (p =3D &amp;&quot;*=3D&gt;@|&quot;[indicator_style - file_type]; *p=
; p++)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set_char_quoting (file=
name_quoting_options, *p, 1);<br>=C2=A0=C2=A0=C2=A0 }<br><br></div>Basicall=
y, it says, if --file-type was used, then we should be sure to quote &#39;=
=3D&#39;, &#39;&gt;&#39;, and &#39;@&#39;. If --classify is used, then we s=
hould do the same but also add in &#39;*&#39;. Or, to put it in less compre=
ssed C:<br><div><div><br>=C2=A0 if (indicator_style =3D=3D file_type)<br>=
=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 char const *p;<br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (p =3D &quot;=3D&gt;@|&quot;; *p; p++)<b=
r>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set_char_quoting (filename_quo=
ting_options, *p, 1);<br>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0 if (indicator_style=
 =3D=3D classify)<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 char const *p;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (p =3D &quot;*=3D&gt;=
@|&quot;; *p; p++)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set_char_q=
uoting (filename_quoting_options, *p, 1);<br>=C2=A0=C2=A0=C2=A0 }<br><br></=
div><div>However, there is no need to quote those characters when the quoti=
ng-style is set to C. In fact, it is an error to do so as these are not val=
id C escape sequences.<br><br></div><div>I am guessing the idea of the code=
 was that those characters would not be backslash escaped, but rather the e=
ntire filename would be wrapped in quotes so the indicator character cannot=
 be confused for part of the filename. And, indeed, this does work for some=
 of the quoting styles: &quot;shell[-escape][-always]&quot; work that way. =
Strangely, &quot;c-maybe&quot; also works that way.<br><br>=C2=A0 $ ls -F -=
-quoting-style=3Dliteral<br>=C2=A0 @<br>=C2=A0 $ ls -F --quoting-style=3Dsh=
ell<br>=C2=A0 &#39;@&#39;<br>=C2=A0 $ ls -F --quoting-style=3Dshell-always<=
br>=C2=A0 &#39;@&#39;<br>=C2=A0 $ ls -F --quoting-style=3Dshell-escape<br>=
=C2=A0 &#39;@&#39;<br>=C2=A0 $ ls -F --quoting-style=3Dshell-escape-<wbr>al=
ways<br>=C2=A0 &#39;@&#39;<br>=C2=A0 $ ls -F --quoting-style=3Dc-maybe<br><=
/div><div>=C2=A0 &quot;@&quot;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # =
&lt;-- This is correct!<br></div><div><br></div><div>I spent some time debu=
gging it, but I didn&#39;t find the perfect fix as I don&#39;t understand w=
hy it was written the way it was. Rather, I found something that I think is=
 an improvement and a step towards doing things right. I&#39;ve made a patc=
h that simply checks if the quoting style is C and skips the problematic li=
nes. Ideally, somebody who understands why this code was written this way i=
n the first place can make a better patch, but this should work for now and=
 not break anything for anybody else.<br><br></div><div>Please find attache=
d below, my patch for src/ls.c and a regression test script to be placed in=
 tests/ls/quoting-style-c.sh. <br><br></div><div>--b9<br><br></div><div>P.S=
. This bug may also apply to the -b (--quoting-style=3Descape). However, th=
e output from it appears to be more like a mish-mash of C and shell escapes=
. (For example, tabs are shown as &quot;\t&quot;, as in C, but spaces are s=
hown as &quot;\ &quot;, as in bourne shell. ) The -Q option, on the other h=
and, generates perfectly acceptable C strings (tested with gcc and python),=
 except for those few buggy characters fixed in this patch. <br><br><br></d=
iv></div></div>

--001a113ac54cf31655056110cc37--

--001a113ac54cf31658056110cc39
Content-Type: text/x-patch; charset="US-ASCII"; name="ls-FQ.patch"
Content-Disposition: attachment; filename="ls-FQ.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jbkf5quy0

LS0tIHNyYy9scy5jLm9yaWcJMjAxNy0wOS0wMSAwMDoxMTowMy4wMDAwMDAwMDAgLTA3MDAKKysr
IHNyYy9scy5jCTIwMTctMTItMjMgMjI6NTM6NTcuNDQ4NTk0NTA3IC0wODAwCkBAIC0yMTM4LDEy
ICsyMTM4LDE5IEBACiAgIGZpbGVuYW1lX3F1b3Rpbmdfb3B0aW9ucyA9IGNsb25lX3F1b3Rpbmdf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nIChkaXJuYW1lX3F1b3Rpbmdfb3B0aW9ucywgJzonLCAxKTsK
--001a113ac54cf31658056110cc39
Content-Type: application/x-sh; name="quoting-style-c.sh"
Content-Disposition: attachment; filename="quoting-style-c.sh"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jbkfbbu41

IyEvYmluL3NoCiMgVGhpcyBpcyB0ZXN0cy9scy9xdW90aW5nLXN0eWxlLWMuc2gKIyB0ZXN0IC0t
cXVvdGluZy1zdHlsZT1jICgtUSkKCiMgVXNhZ2U6CiMgICBjZCB0ZXN0cwojICAgbWFrZSBjaGVj
ayBURVNUUz1scy9xdW90aW5nLXN0eWxlLWMuc2gKCiMgdjE6IEZvciBub3csIHdlJ3JlIGp1c3Qg
d2F0Y2hpbmcgZm9yIHJlZ3Jlc3Npb25zIHdpdGggLS1jbGFzc2lmeSAoLUYpCiMKCiMgQ29weXJp
Z2h0IChDKSAyMDE3IEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbiwgSW5jLgoKIyBUaGlzIHByb2dy
YW0gaXMgZnJlZSBzb2Z0d2FyZTogeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yIG1vZGlm
eQojIGl0IHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgR05VIEdlbmVyYWwgUHVibGljIExpY2Vuc2Ug
YXMgcHVibGlzaGVkIGJ5CiMgdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbiwgZWl0aGVyIHZl
cnNpb24gMyBvZiB0aGUgTGljZW5zZSwgb3IKIyAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2
ZXJzaW9uLgoKIyBUaGlzIHByb2dyYW0gaXMgZGlzdHJpYnV0ZWQgaW4gdGhlIGhvcGUgdGhhdCBp
dCB3aWxsIGJlIHVzZWZ1bCwKIyBidXQgV0lUSE9VVCBBTlkgV0FSUkFOVFk7IHdpdGhvdXQgZXZl
biB0aGUgaW1wbGllZCB3YXJyYW50eSBvZgojIE1FUkNIQU5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clwz
NjNmb28iCiJiYXJcMzY0Zm9vIgoiYmFyXDM2NWZvbyIKImJhclwzNjZmb28iCiJiYXJcMzY3Zm9v
IgoiYmFyXDM3MGZvbyIKImJhclwzNzFmb28iCiJiYXJcMzcyZm9vIgoiYmFyXDM3M2ZvbyIKImJh
clwzNzRmb28iCiJiYXJcMzc1Zm9vIgoiYmFyXDM3NmZvbyIKImJhclwzNzdmb28iCiJleHAiCiJu
b2JhY2tzbGFzaCAiCiJub2JhY2tzbGFzaCoiCiJub2JhY2tzbGFzaDoiCiJub2JhY2tzbGFzaDwi
CiJub2JhY2tzbGFzaD0iCiJub2JhY2tzbGFzaD4iCiJub2JhY2tzbGFzaEAiCiJub2JhY2tzbGFz
aHwiCiJvdXJvYm9yb3MiQAoib3V0IgoieWVzYmFja3NsYXNoYmVmb3JlYmFja3NsYXNoXFwiCiJ5
ZXNiYWNrc2xhc2hiZWZvcmVkb3VibGVxdW90ZVwiIgpFT0YKCmxzIC0tY2xhc3NpZnkgLS1xdW90
aW5nLXN0eWxlPWMgPiBvdXQgfHwgZmFpbD0xCgpjb21wYXJlIGV4cCBvdXQgfHwgZmFpbD0xCgpF
eGl0ICRmYWlsCg==
--001a113ac54cf31658056110cc39--




Acknowledgement sent to hackerb9@HIDDEN:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#29832; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 30 Oct 2018 02:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.