mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
cksum: improve the blake2b detection algo corner case
This commit is contained in:
parent
db58d2b6b5
commit
514d810371
2 changed files with 23 additions and 1 deletions
|
@ -436,7 +436,7 @@ where
|
||||||
// 1. <algo>[-<bits>] (<filename>) = <checksum>
|
// 1. <algo>[-<bits>] (<filename>) = <checksum>
|
||||||
// algo must be uppercase or b (for blake2b)
|
// algo must be uppercase or b (for blake2b)
|
||||||
// 2. <checksum> [* ]<filename>
|
// 2. <checksum> [* ]<filename>
|
||||||
let regex_pattern = r"^\s*\\?(?P<algo>[A-Z0-9b]+)(-(?P<bits>\d+))?\s?\((?P<filename1>.*)\) = (?P<checksum1>[a-fA-F0-9]+)$|^(?P<checksum2>[a-fA-F0-9]+)\s[* ](?P<filename2>.*)";
|
let regex_pattern = r"^\s*\\?(?P<algo>(?:[A-Z0-9]+|BLAKE2b))(?:-(?P<bits>\d+))?\s?\((?P<filename1>.*)\) = (?P<checksum1>[a-fA-F0-9]+)$|^(?P<checksum2>[a-fA-F0-9]+)\s[* ](?P<filename2>.*)";
|
||||||
let re = Regex::new(regex_pattern).unwrap();
|
let re = Regex::new(regex_pattern).unwrap();
|
||||||
|
|
||||||
// if cksum has several input files, it will print the result for each file
|
// if cksum has several input files, it will print the result for each file
|
||||||
|
|
|
@ -1119,6 +1119,28 @@ fn test_blake2b_bits() {
|
||||||
.stderr_contains("f: no properly formatted checksum lines found");
|
.stderr_contains("f: no properly formatted checksum lines found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_bsd_case() {
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
at.write("f", "bSD (README.md) = 0000\n");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-c")
|
||||||
|
.arg("f")
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("f: no properly formatted checksum lines found");
|
||||||
|
at.write("f", "BsD (README.md) = 0000\n");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-c")
|
||||||
|
.arg("f")
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("f: no properly formatted checksum lines found");
|
||||||
|
}
|
||||||
|
|
||||||
#[ignore = "Different output"]
|
#[ignore = "Different output"]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_blake2d_tested_with_sha1() {
|
fn test_blake2d_tested_with_sha1() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue