From 8da2f6ef09c94fd012042cd0c1f0b480c8acc619 Mon Sep 17 00:00:00 2001 From: Nathaniel Taintor Date: Thu, 26 Feb 2026 10:06:09 -0500 Subject: [PATCH] Guard against fatal when block has no inner HTML Trim HTML before processing in extract_value_from_html --- src/Data.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Data.php b/src/Data.php index 72c6ab6..0557abf 100644 --- a/src/Data.php +++ b/src/Data.php @@ -188,8 +188,14 @@ private function extract_value_from_meta( array $attribute, ?int $post_id ) { */ private function extract_value_from_html( array $attribute, string $html, ?int $post_id = null ) { $value = null; + $html = trim( $html ); + + if ( empty( $html ) ) { + return null; + } + try { - $dom = new Document( trim( $html ) ); + $dom = new Document( $html ); $node = isset( $attribute['selector'] ) ? $dom->find( $attribute['selector'] ) : [ $dom->first( '*' ) ]; } catch ( InvalidSelectorException $e ) {