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:
parent
9abf9d0fb5
commit
d414dbc83b
2 changed files with 21 additions and 3 deletions
|
@ -11,7 +11,7 @@ use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
|
|||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
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,
|
||||
};
|
||||
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
|
||||
|
@ -226,11 +226,11 @@ pub fn get_supports_fast_decode_and_encode(
|
|||
|
||||
match format {
|
||||
Format::Base16 => Box::from(EncodingWrapper::new(
|
||||
HEXUPPER,
|
||||
HEXUPPER_PERMISSIVE,
|
||||
BASE16_VALID_DECODING_MULTIPLE,
|
||||
BASE16_UNPADDED_MULTIPLE,
|
||||
// spell-checker:disable-next-line
|
||||
b"0123456789ABCDEF",
|
||||
b"0123456789ABCDEFabcdef",
|
||||
)),
|
||||
Format::Base2Lsbf => Box::from(EncodingWrapper::new(
|
||||
BASE2LSBF,
|
||||
|
|
|
@ -130,6 +130,24 @@ fn test_base16_decode() {
|
|||
.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]
|
||||
fn test_base2msbf() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue