Search by

timmit / xss-filter

timmit

basic XSS Filter, based on symfony xss filter

Package info

github.com/timmit-nl/xss-filter

pkg:composer/timmit/xss-filter

Statistics

Installs: 4 962

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v3.1.3 2026-11-27 11:33 UTC

README

Checks and cleans strings with voku/anti-xss. The class is TiMMiT\XSS_Filter.

Install

composer require timmit/xss-filter

This package requires voku/anti-xss ^4.1. Composer loads the class from src/TiMMiT/XSS-Filter/XSS_Filter.php.

Usage

check4XSSInRequestArrays() scans $_POST, $_GET, and $_COOKIE. It returns true when XSS is found.

use TiMMiT\XSS_Filter;

if (XSS_Filter::check4XSSInRequestArrays(true)) {
    // a value in $_POST, $_GET, or $_COOKIE contained XSS
}

The first argument writes cleaned strings back into those arrays when it is true. The second argument chooses the tag list: true blocks the known HTML tags, false blocks img, a, b, strong, and i. null keeps the list from the previous call. The default is the shorter list. The third argument also scans string keys.

detectXSSInArray() does the same walk for one array, including nested arrays:

$found = XSS_Filter::detectXSSInArray($payload, true, true, true);

cleanString() returns the cleaned string and does not report whether XSS was found:

$clean = XSS_Filter::cleanString($value, true);

reset() drops the current cleaner, so the next call builds a new one.

License

MIT.