TestNew | Default middleware with XSS input | HTML entities escaped (e.g., <script> becomes <script>) |
TestWithOptions_TrimSpaces | TrimSpaces option with padded input | Leading and trailing spaces removed (" John " becomes "John") |
TestWithOptions_StripTags | StripTags option with HTML content | All HTML tags removed including script tags ("<p>Hello</p><script>bad</script>World" becomes "HelloWorld") |
TestWithOptions_MaxLength | MaxLength option with long input | Value truncated to specified length ("VeryLongName" becomes "VeryL" with MaxLength=5) |
TestWithOptions_Fields | Fields whitelist with multiple parameters | Only specified fields sanitized, others passed through unchanged |
TestWithOptions_Exclude | Exclude blacklist with multiple parameters | Excluded fields bypass sanitization, others are sanitized |
TestXSS | XSS prevention preset | Script tags escaped to prevent XSS attacks |
TestStripHTML | HTML stripping preset | All HTML tags removed from input |
TestTrim | Trim whitespace preset | Leading and trailing whitespace removed |
TestSanitize | Direct sanitization function with various options | Correct sanitization applied: HTML escape, trim, strip tags, max length |
TestSanitizeHTML | HTML sanitization helper | HTML escaped and trimmed |
TestStripTagsString | Tag stripping helper | HTML tags removed from string |
TestTrimString | Trim helper function | Whitespace trimmed from string |
TestClean | All-in-one cleaning function | All sanitization operations applied (HTML escape, trim, strip tags, strip non-printable) |
TestWithOptions_StripNonPrintable | Non-printable character removal | Control characters removed ("hello\x00world\x1f" becomes "helloworld") |