1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

basenc: ignore case with "--base16 --decode"

This commit is contained in:
Daniel Hofstetter 2024-12-17 10:52:25 +01:00
parent 9abf9d0fb5
commit d414dbc83b
2 changed files with 21 additions and 3 deletions

View file

@ -11,7 +11,7 @@ use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::encoding::{ use uucore::encoding::{
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER}, for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER_PERMISSIVE},
Format, Z85Wrapper, BASE2LSBF, BASE2MSBF, Format, Z85Wrapper, BASE2LSBF, BASE2MSBF,
}; };
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode}; use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
@ -226,11 +226,11 @@ pub fn get_supports_fast_decode_and_encode(
match format { match format {
Format::Base16 => Box::from(EncodingWrapper::new( Format::Base16 => Box::from(EncodingWrapper::new(
HEXUPPER, HEXUPPER_PERMISSIVE,
BASE16_VALID_DECODING_MULTIPLE, BASE16_VALID_DECODING_MULTIPLE,
BASE16_UNPADDED_MULTIPLE, BASE16_UNPADDED_MULTIPLE,
// spell-checker:disable-next-line // spell-checker:disable-next-line
b"0123456789ABCDEF", b"0123456789ABCDEFabcdef",
)), )),
Format::Base2Lsbf => Box::from(EncodingWrapper::new( Format::Base2Lsbf => Box::from(EncodingWrapper::new(
BASE2LSBF, BASE2LSBF,

View file

@ -130,6 +130,24 @@ fn test_base16_decode() {
.stdout_only("Hello, World!"); .stdout_only("Hello, World!");
} }
#[test]
fn test_base16_decode_lowercase() {
new_ucmd!()
.args(&["--base16", "-d"])
.pipe_in("48656c6c6f2c20576f726c6421")
.succeeds()
.stdout_only("Hello, World!");
}
#[test]
fn test_base16_decode_and_ignore_garbage_lowercase() {
new_ucmd!()
.args(&["--base16", "-d", "-i"])
.pipe_in("48656c6c6f2c20576f726c6421")
.succeeds()
.stdout_only("Hello, World!");
}
#[test] #[test]
fn test_base2msbf() { fn test_base2msbf() {
new_ucmd!() new_ucmd!()