basenc: --base16: support lower case hex digits

* src/basenc.c (base16_decode_ctx): Convert to uppercase
before converting from hex.
* tests/basenc/basenc.pl: Add a test case.
* NEWS: Mention the change in behavior.
Addresses https://bugs.gnu.org/66698
This commit is contained in:
Pádraig Brady committed 2023-10-23 14:04:38 +01:00
1 parent 2e0dcd87bf
commit d733f2ec26
3 files changed
+5 -1

No files matched your search

+3
View File
@@ -19,6 +19,9 @@ GNU coreutils NEWS -*- outline -*-
base32 and base64 no longer require padding when decoding.
Previously an error was given for non padded encoded data.
basenc --base16 -d now supports lower case hexadecimal characters.
Previously an error was given for lower case hex digits.
ls --dired now implies long format output without hyperlinks enabled,
and will take precedence over previously specified formats or hyperlink mode.
+1 -1
View File
@@ -577,7 +577,7 @@ base16_decode_ctx (struct base_decode_context *ctx,
continue;
}
int nib = *in++;
int nib = c_toupper (*in++);
if ('0' <= nib && nib <= '9')
nib -= '0';
else if ('A' <= nib && nib <= 'F')
+1
View File
@@ -159,6 +159,7 @@ my @Tests =
['b16_7', '--base16 -d', {IN=>'G'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b16_8', '--base16 -d', {IN=>"AB\nCD"}, {OUT=>"\xAB\xCD"}],
['b16_9', '--base16 -d', {IN=>lc ($base16_out)}, {OUT=>$base16_in}],