Subject: bug#64392: cksum: escaping issues of --check output

From: Pádraig Brady <[email-masked]>
Date: Sat, 1 Jul 2023 18:53:10 +0100

On 01/07/2023 18:20, Christoph Anton Mitterer wrote:
> On Sat, 2023-07-01 at 17:07 +0100, Pádraig Brady wrote:
>> Right. We traditionally didn't escape any chars in the --check
>> output,
>> but that changed with
>> https://github.com/coreutils/coreutils/commit/646902b30
>> To minimize escaping, that patch only considered the '\n' character,
>> but we should also have considered file names with a leading '\'.
>>
>> The attached should address this.
> 
> Thanks, but wouldn't it be better to use exactly the same escaping as
> in the sums output? I.e. also escaping \r?

Yes maybe. I was thinking this status output would be less likely to be persisted,
and so would not need the same escaping requirements,
but for consistency it may be better to have the same escaping rules,
with the caveat that file names with a literal backslash anywhere
would now be escaped. That's not a common case I suppose,
so I'm amenable to using the consistent escaping here.

> Also, documenting the escaping behaviour in info/manpages?

Info docs already contain:

"Without ‘--zero’, if FILE contains a backslash, newline, or carriage
return, the line is started with a backslash, and each problematic
character in the file name is escaped with a backslash, making the
output unambiguous even in the presence of arbitrary file names."

cheers,
Pádraig