(path: &[u8])
| 256 | } |
| 257 | |
| 258 | fn validate_path(path: &[u8]) -> PristineResult<()> { |
| 259 | if path.is_empty() || path[0] == b'/' || path.contains(&0) { |
| 260 | return Err(codec_error( |
| 261 | "FILE_INDEX_V2 path is not a canonical relative path", |
| 262 | )); |
| 263 | } |
| 264 | if path |
| 265 | .split(|byte| *byte == b'/') |
| 266 | .any(|part| part.is_empty() || part == b"." || part == b"..") |
| 267 | { |
| 268 | return Err(codec_error( |
| 269 | "FILE_INDEX_V2 path has a non-canonical component", |
| 270 | )); |
| 271 | } |
| 272 | Ok(()) |
| 273 | } |
| 274 | |
| 275 | fn validate_entry(entry: &FileIndexV2Entry) -> PristineResult<()> { |
| 276 | validate_presence( |
no test coverage detected