mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
split: directory separator in additional suffix
This commit is contained in:
committed by
Sylvestre Ledru
parent
f05474a33a
commit
62887c7a58
@@ -40,6 +40,7 @@ use crate::{
|
||||
};
|
||||
use clap::ArgMatches;
|
||||
use std::fmt;
|
||||
use std::path::is_separator;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
|
||||
@@ -230,7 +231,7 @@ impl Suffix {
|
||||
.get_one::<String>(OPT_ADDITIONAL_SUFFIX)
|
||||
.unwrap()
|
||||
.to_string();
|
||||
if additional.contains('/') || additional.contains('\\') {
|
||||
if additional.chars().any(is_separator) {
|
||||
return Err(SuffixError::ContainsSeparator(additional));
|
||||
}
|
||||
|
||||
|
||||
@@ -247,11 +247,14 @@ fn test_split_additional_suffix() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_additional_suffix_no_slash() {
|
||||
fn test_additional_suffix_dir_separator() {
|
||||
#[cfg(unix)]
|
||||
new_ucmd!()
|
||||
.args(&["--additional-suffix", "a/b"])
|
||||
.fails()
|
||||
.usage_error("invalid suffix 'a/b', contains directory separator");
|
||||
|
||||
#[cfg(windows)]
|
||||
new_ucmd!()
|
||||
.args(&["--additional-suffix", "a\\b"])
|
||||
.fails()
|
||||
|
||||
Reference in New Issue
Block a user