bug-coreutils
[Top][All Lists]
Advanced

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

bug#66698: I think hex decoding with basenc -d --base16 should be case-i


From: Pádraig Brady
Subject: bug#66698: I think hex decoding with basenc -d --base16 should be case-insensitive
Date: Wed, 25 Oct 2023 14:27:41 +0100
User-agent: Mozilla Thunderbird

On 25/10/2023 02:30, Paul Eggert wrote:
On 10/23/23 06:08, Pádraig Brady wrote:
However the default operation should be the
most common requirement (and also the RFC documented operation in this
case).
A similar case I hit very frequently is pasting hex into bc, and it's
very annoying to have to convert to uppercase before doing this.

Doesn't the isbase16 function also need updating?

Good spot. I'm adding this, and also a test
for this --ignore-garbage case.

diff --git a/src/basenc.c b/src/basenc.c
 isbase16 (char ch)
 {
-  return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'F');
+  return isxdigit (to_uchar (ch));
 }


Also, shouldn't we do something similar for base 32, for consistency?

I was wondering about that.

I previously checked the RFC which didn't mention lower case for base32.
But thinking about it more we probably should allow lower case for base32.

This is also related to the base64 padding change I think, in that we
might add a --strict option to only accept canonical (upper case base32) inputs.
That would also only accept canonical padding, and canonical encoding
of the trailing bits. For example would reject 'SGVsbG9='. See:
https://eprint.iacr.org/2022/361.pdf

thanks,
Pádraig.





reply via email to

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