Skip to content

Commit b21ed57

Browse files
committed
Use spawn_fragment_parser + serialize to normalize
1 parent de06d0b commit b21ed57

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,23 @@ public function set_inner_html( ?string $html ) {
379379
return false;
380380
}
381381

382-
$html = $html ? $this->normalize( $html ) : '';
382+
if ( null === $html ) {
383+
$html = '';
384+
}
385+
if ( '' !== $html ) {
386+
$fragment_parser = $this->spawn_fragment_parser( $html );
387+
if (
388+
null === $fragment_parser
389+
) {
390+
return false;
391+
}
392+
393+
try {
394+
$html = $fragment_parser->serialize();
395+
} catch ( Exception $e ) {
396+
return false;
397+
}
398+
}
383399

384400
// @todo apply modifications if there are any???
385401

0 commit comments

Comments
 (0)