|
cwist
Modern C web framework with libttak runtime
|
Deterministic request firewall and output sanitization. More...


Go to the source code of this file.
Functions | |
| cwist_middleware_func | cwist_mw_waf_lite (void) |
| Construct the WAF-lite middleware. | |
| bool | cwist_waf_is_safe (const char *input, size_t length) |
| Check whether a byte string is free of hostile signatures. | |
| char * | cwist_sanitize_html (const char *input) |
| Escape HTML-special characters in a NUL-terminated string. | |
Deterministic request firewall and output sanitization.
Definition in file waf.h.
| cwist_middleware_func cwist_mw_waf_lite | ( | void | ) |
Escape HTML-special characters in a NUL-terminated string.
Replaces '&', '<', '>', '"', and '\'' with their HTML entity equivalents and returns a newly allocated buffer holding the escaped text.
| input | Input string; may be NULL. |
input is NULL, on allocation failure, or on size overflow. Definition at line 141 of file waf.c.
References cap, and cwist_alloc().
Check whether a byte string is free of hostile signatures.
Scans input once (O(length)) through the case-insensitive Aho-Corasick automaton, which is built lazily on first call. Matching is ASCII-only: bytes at or above 0x80 reset the automaton state, and control bytes other than tab, newline, and carriage return are rejected outright.
| input | Byte string to scan; may be NULL. |
| length | Number of bytes to scan. |
Definition at line 113 of file waf.c.
References cap, and WAF_ALPHABET.