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

Function validate_repo_path

atomic-repository/src/repository/project_tree.rs:212–235  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

210}
211
212fn validate_repo_path(bytes: &[u8]) -> Result<(), ProjectTreeError> {
213 if bytes.is_empty() {
214 return Err(ProjectTreeError::InvalidPath("path is empty".into()));
215 }
216 if bytes[0] == b'/' {
217 return Err(ProjectTreeError::InvalidPath("path is absolute".into()));
218 }
219 if bytes.contains(&0) {
220 return Err(ProjectTreeError::InvalidPath("path contains NUL".into()));
221 }
222 for component in bytes.split(|byte| *byte == b'/') {
223 if component.is_empty() {
224 return Err(ProjectTreeError::InvalidPath(
225 "path contains an empty component".into(),
226 ));
227 }
228 if component == b"." || component == b".." {
229 return Err(ProjectTreeError::InvalidPath(
230 "path contains '.' or '..'".into(),
231 ));
232 }
233 }
234 Ok(())
235}
236
237#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
238pub enum ExclusionReason {

Callers 1

newMethod · 0.85

Calls 2

is_emptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected