19 declare(strict_types=1);
39 public function isValid():
bool 41 if (!preg_match(
'/<[^>]+?>/', $this->text)) {
46 set_error_handler(
static function (
int $severity,
string $message,
string $file,
int $line):
void {
47 throw new ErrorException($message, $severity, $severity, $file, $line);
53 $import_succeeded = $dom->loadHTML($this->text);
63 RecursiveIteratorIterator::SELF_FIRST
65 foreach ($iter as $element) {
67 if (strtolower($element->nodeName) ===
'body') {
71 if ($element->nodeType === XML_ELEMENT_NODE) {
81 restore_error_handler();
87 $this->xmlErrorState = libxml_use_internal_errors(
true);
88 libxml_clear_errors();
93 $currentErrors = libxml_get_errors();
94 libxml_clear_errors();
96 $this->xmlErrors = $currentErrors;
103 libxml_use_internal_errors($this->xmlErrorState);
111 return array_filter($this->xmlErrors,
static function (
LibXMLError $error):
bool {
112 return $error->code !== self::LIBXML_CODE_HTML_UNKNOWN_TAG;
Class ilTermsOfServiceDocumentsContainsHtmlValidator.
__construct(string $text)
Class ilHtmlDomNodeIterator.
const LIBXML_CODE_HTML_UNKNOWN_TAG