pub struct PathValidator;Expand description
路径安全验证工具
Implementations§
Source§impl PathValidator
impl PathValidator
Sourcepub fn sanitize_path(user_input: &str) -> UploadResult<String>
pub fn sanitize_path(user_input: &str) -> UploadResult<String>
验证路径安全性,防止路径遍历攻击
对应 TypeScript 版本的 sanitizePath
Sourcepub fn validate_target_path(
target_path: &Path,
base_path: &Path,
) -> UploadResult<()>
pub fn validate_target_path( target_path: &Path, base_path: &Path, ) -> UploadResult<()>
验证最终路径是否在允许的目录内
对应 TypeScript 版本的 validateTargetPath
Auto Trait Implementations§
impl Freeze for PathValidator
impl RefUnwindSafe for PathValidator
impl Send for PathValidator
impl Sync for PathValidator
impl Unpin for PathValidator
impl UnsafeUnpin for PathValidator
impl UnwindSafe for PathValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more