MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / validate_path

Function validate_path

atomic-core/src/pristine/file_index_v2.rs:258–273  ·  view source on GitHub ↗
(path: &[u8])

Source from the content-addressed store, hash-verified

256}
257
258fn 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
275fn validate_entry(entry: &FileIndexV2Entry) -> PristineResult<()> {
276 validate_presence(

Callers 1

newMethod · 0.85

Calls 3

codec_errorFunction · 0.70
is_emptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected