From fd0deb9b5102aa092ff6fbe6d08039277492873c Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 23 Sep 2022 05:07:55 +0000 Subject: [PATCH] Allow paths to contain `*` From #377, the [TUF spec] allows for paths to contain `*`. According to @lukesteensen, this is routinely used in delegations. Note though this does not attempt to implement delegation path globs. That will be implemented in #388. [TUF spec]: https://theupdateframework.github.io/specification/latest/#targetpath --- tuf/src/metadata.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tuf/src/metadata.rs b/tuf/src/metadata.rs index d8aa7e3..77165ce 100644 --- a/tuf/src/metadata.rs +++ b/tuf/src/metadata.rs @@ -66,7 +66,6 @@ static PATH_ILLEGAL_STRINGS: &[&str] = &[ "\"", "|", "?", - "*", // control characters, all illegal in FAT "\u{000}", "\u{001}", @@ -2314,6 +2313,23 @@ mod test { } } + #[test] + fn allow_asterisk_in_target_path() { + let good_paths = &[ + "*", + "*/some/path", + "*/some/path/", + "some/*/path", + "some/*/path/*", + ]; + + for path in good_paths.iter() { + assert!(safe_path(path).is_ok()); + assert!(TargetPath::new(path.to_string()).is_ok()); + assert!(MetadataPath::new(path.to_string()).is_ok()); + } + } + #[test] fn path_matches_chain() { let test_cases: &[(bool, &str, &[&[&str]])] = &[