Add HTML Purify to BBCode::convert

- Replace previous HTML cleanup using DOMDocument
- Remove obsolete HTML::sanitizeCSS method
- Use Strings::autoLinkRegEx for PageInfo::getRelevantUrlFromBody
- Update previous tests expectations
- Add new specific XSS tests
This commit is contained in:
Hypolite Petovan 2020-12-04 07:27:13 -05:00
parent d8e3b841f8
commit a0f6d678c4
4 changed files with 83 additions and 111 deletions

View file

@ -36,27 +36,6 @@ use League\HTMLToMarkdown\HtmlConverter;
class HTML
{
public static function sanitizeCSS($input)
{
$cleaned = "";
$input = strtolower($input);
for ($i = 0; $i < strlen($input); $i++) {
$char = substr($input, $i, 1);
if (($char >= "a") && ($char <= "z")) {
$cleaned .= $char;
}
if (!(strpos(" #;:0123456789-_.%", $char) === false)) {
$cleaned .= $char;
}
}
return $cleaned;
}
/**
* Search all instances of a specific HTML tag node in the provided DOM document and replaces them with BBCode text nodes.
*