Expand description
Small string helpers without external dependencies.
Functionsยง
- content_
disposition Content-Dispositionvalue that forces a download and keeps non-ASCII file names intact (RFC 6266 / RFC 5987).- csv_
field - Escapes a CSV field (RFC 4180). Fields starting with characters that
spreadsheet programs interpret as formulas are prefixed with
'. - format_
bytes - Human readable byte size (binary units).
- format_
number - Formats a number with up to
decimalsdecimals, trimming trailing zeros. - pct_
encode - Percent-encodes everything except RFC 3986 unreserved characters.
- safe_
redirect_ target - Only accept local, absolute paths as redirect targets (prevents open
redirects via
?next=https://evil.example). - sanitize_
filename - Reduces an uploaded file name to a safe base name.