Skip to main content

clean_edit_path

Function clean_edit_path 

Source
pub fn clean_edit_path(p: &str) -> Option<String>
Expand description

Validate a repo-relative edit path (JSS cleanEditPath). Returns the clean path, or None.

Refused: empty or longer than EDIT_PATH_CAP, a leading /, a backslash, a control character (NUL included), an empty segment, .., any .git segment in any letter case, a segment outside [A-Za-z0-9._-], and a dotfile at the repository root (.acl, .htaccess).

ยงExamples

use solid_pod_rs_forge::web_edit::clean_edit_path;

assert!(clean_edit_path("index.html").is_some());
assert!(clean_edit_path("docs/.hidden").is_some());
for bad in ["", "/etc/x", "a/../b", "a\\b", ".git/x", "a/.Git/x", ".acl", "a//b", "a\0b"] {
    assert!(clean_edit_path(bad).is_none(), "{bad:?}");
}