What are the potential pitfalls of using HTMLPurifier incorrectly in PHP?

Using HTMLPurifier incorrectly in PHP can lead to security vulnerabilities such as cross-site scripting (XSS) attacks. To prevent this, it is important to properly configure HTMLPurifier with the appropriate settings and filters to sanitize user input before displaying it on a webpage.

// Example of using HTMLPurifier with proper configuration
require_once 'path/to/HTMLPurifier.auto.php';

$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', ''); // Allow only safe HTML tags
$purifier = new HTMLPurifier($config);

$dirty_html = '<script>alert("XSS attack!")</script>';
$clean_html = $purifier->purify($dirty_html);

echo $clean_html;