Skip to main content

sanitize_filename

Function sanitize_filename 

Source
pub fn sanitize_filename(raw: &str) -> String
Expand description

Strips a client filename to a safe basename capped at 255 bytes, without control or bidirectional-override characters, rejecting ., .., and Windows reserved names to empty: what a file field’s Uploader receives, for a page that parses its own multipart body.

assert_eq!(tablo_core::sanitize_filename("../../etc/passwd"), "passwd");
assert_eq!(
    tablo_core::sanitize_filename("C:\\fakepath\\cover.png"),
    "cover.png"
);
assert_eq!(tablo_core::sanitize_filename(".."), "");