File tree Expand file tree Collapse file tree
phpmyfaq/src/phpMyFAQ/Helper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,7 +168,14 @@ public function cleanUpContent(string $content): string
168168 ->allowMediaHosts ($ allowedHosts )
169169 ->allowLinkSchemes (['https ' , 'http ' , 'mailto ' , 'data ' ]));
170170
171- $ sanitizedContent = $ htmlSanitizer ->sanitize ($ content );
171+ // Suppress HTML parser warnings during sanitization, as Dom\HTMLDocument::createFromString()
172+ // emits tokenizer warnings for slightly malformed user-generated HTML content
173+ $ previousErrorReporting = error_reporting (E_ALL & ~E_WARNING );
174+ try {
175+ $ sanitizedContent = $ htmlSanitizer ->sanitize ($ content );
176+ } finally {
177+ error_reporting ($ previousErrorReporting );
178+ }
172179
173180 $ sanitizedContent = preg_replace ('/<iframe\b(?:(?!src)[^>])*>\s*<\/iframe>/i ' , '' , $ sanitizedContent );
174181
You can’t perform that action at this time.
0 commit comments