Skip to content

Commit

Permalink
Add missing function for FormValidator filters - refs BT#22293
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Feb 12, 2025
1 parent dbbccff commit fb9a1af
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions public/main/inc/lib/formvalidator/FormValidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1988,3 +1988,30 @@ function mobile_phone_number_filter($mobilePhoneNumber)

return ltrim($mobilePhoneNumber, '0');
}

/**
* Cleans JS from a URL.
*
* @param string $html URL to clean
* @param int $mode (optional)
*
* @return string The cleaned URL
*/
function plain_url_filter($html, $mode = NO_HTML)
{
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$html = kses_no_null($html);
$html = kses_js_entities($html);
$allowed_html_fixed = kses_array_lc($allowed_tags);

return kses_split($html, $allowed_html_fixed, ['http', 'https']);
}

/**
* Prevent execution of event handlers in HTML elements.
*/
function attr_on_filter(string $html): string
{
return RemoveOnAttributes::filter($html);
}

0 comments on commit fb9a1af

Please sign in to comment.