mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
Merge pull request #8558 from cakebaker/basenc_allow_non_utf8_filenames
basenc: allow non-UTF8 filenames
This commit is contained in:
commit
70a7b034f4
2 changed files with 30 additions and 2 deletions
|
|
@ -63,7 +63,7 @@ pub fn uu_app() -> Command {
|
|||
}
|
||||
|
||||
fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
|
||||
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args.collect_lossy())?;
|
||||
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
|
||||
|
||||
let encodings = get_encodings();
|
||||
let format = encodings
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// spell-checker: ignore (encodings) lsbf msbf
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::{at_and_ucmd, new_ucmd};
|
||||
|
||||
#[test]
|
||||
fn test_z85_not_padded_decode() {
|
||||
|
|
@ -270,3 +270,31 @@ fn test_z85_length_check() {
|
|||
.succeeds()
|
||||
.stdout_only("12345678");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_file() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let filename = "file";
|
||||
|
||||
at.write(filename, "foo");
|
||||
|
||||
ucmd.arg(filename)
|
||||
.arg("--base64")
|
||||
.succeeds()
|
||||
.stdout_is("Zm9v\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_file_with_non_utf8_name() {
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let filename = std::ffi::OsString::from_vec(vec![0xFF, 0xFE]);
|
||||
std::fs::write(at.plus(&filename), b"foo").unwrap();
|
||||
|
||||
ucmd.arg(filename)
|
||||
.arg("--base64")
|
||||
.succeeds()
|
||||
.stdout_is("Zm9v\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue