PLSanitizeAttachmentName

Data types

Description

PLSanitizeAttachmentName prepares a file name for use as a mail attachment display name

The function strips any leading path, replaces the characters that mail systems and file systems reject, and never returns an empty name

The MailSendDemo passes deliberately hostile names through it before attaching

Syntax

Delphi

Function PLSanitizeAttachmentName(Const FileName: WideString): WideString;

Fields

FileNameThe candidate file name or full path

Return value

The sanitised base name

Remarks

Path separators of both kinds are stripped, so C:\data\report.pdf yields report.pdf

A name that is empty after path stripping, or . or .., becomes document.pdf

Control characters below 32 and the characters <>:"/\|?* are each replaced with an underscore

See also

PLCreateDefaultMailProvider, TPDFlibMailRequest, IPDFlibMailProvider