Skip to main content

check_name

Function check_name 

Source
pub fn check_name(name: &str) -> Result<(), FormatError>
Expand description

Whether name can name an attachment, and why not if it can’t.

A name is a relative path: folders and a file name joined by /, none of them empty, . or ... It holds no \, no : and no control character, since each can reach outside the folder a container is unpacked into on some system. No part is longer than MAX_PART_BYTES, none ends in . or a space, and none is a Windows device name (CON, PRN, AUX, NUL, CONIN$, CONOUT$, COM0 to COM9, LPT0 to LPT9, COM or LPT with ¹, ² or ³, with or without an extension or spaces before it), which Windows would drop or open as a device. And neither it nor its first folder is DESIGN_ENTRY, ignoring case and how an accent is spelled.

§Errors

FormatError::Container, with the reason.