Skip to main content

classify_relative_path

Function classify_relative_path 

Source
pub fn classify_relative_path(path: &str) -> PathRejection
Expand description

Classify path against the “relative paths only, no ..” policy.

Checks the absolute case before the traversal case, so a path that is both absolute and contains .. is reported as PathRejection::Absolute.

§Examples

use zeph_common::path_guard::{PathRejection, classify_relative_path};

assert_eq!(classify_relative_path("photo.jpg"), PathRejection::Allowed);
assert_eq!(classify_relative_path("/etc/passwd"), PathRejection::Absolute);
assert_eq!(classify_relative_path("../../etc/passwd"), PathRejection::Traversal);