View source
<?php
namespace Drupal\xbbcode;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
class XssEscape extends Xss {
protected static function split($string, $html_tags, $class) : string {
if (!is_subclass_of($class, Xss::class)) {
$class = static::class;
}
$output = parent::split($string, $html_tags, $class);
if ($output !== '') {
return $output;
}
if (!preg_match('%^<\\s*(/\\s*)?([a-zA-Z0-9\\-]+)\\s*([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) {
return Html::escape($string);
}
$elem = $matches[2];
if ($class::needsRemoval($html_tags, $elem)) {
return Html::escape($string);
}
return '';
}
}