Skip to content

Commit

Permalink
Add missing RemoveOnAttributes class for FormValidator filter - refs …
Browse files Browse the repository at this point in the history
…BT#22293
  • Loading branch information
AngelFQC committed Feb 12, 2025
1 parent fb9a1af commit 3e5d9de
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions public/main/inc/lib/formvalidator/FormValidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/* For licensing terms, see /license.txt */

use Chamilo\CoreBundle\Component\HTMLPurifier\Filter\RemoveOnAttributes;

/**
* Class FormValidator
* create/manipulate/validate user input.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/* For licensing terms, see /license.txt */

declare(strict_types=1);

namespace Chamilo\CoreBundle\Component\HTMLPurifier\Filter;

use HTMLPurifier_Filter;

class RemoveOnAttributes extends HTMLPurifier_Filter
{
/**
* @var string
*/
public $name = 'RemoveOnAttributes';

public function preFilter($html, $config, $context): string
{
return self::filter($html);
}

public static function filter($html): string
{
$pattern = '/\s*on\w+=(?:"[^"]*"|\'[^\']*\'|[^\s>]+)/i';

return preg_replace($pattern, '', $html);
}
}

0 comments on commit 3e5d9de

Please sign in to comment.