Skip to content

Commit e33858d

Browse files
🩹 Improve comment removal in Document class by using a non-greedy regex match.
1 parent c5944f1 commit e33858d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎src/Document.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public function html(): string
7474
// Remove XML declaration/comment that libxml2 may add
7575
// Handles both <?xml encoding="UTF-8"> and any comments libxml2 adds
7676
$html = preg_replace('/^<\?xml[^>]*>\s*/i', '', $html);
77-
$html = preg_replace('/^<!--[^>]*-->\s*/', '', $html);
77+
// Use non-greedy match to handle comments containing > characters
78+
$html = preg_replace('/^<!--.*?-->\s*/s', '', $html);
7879

7980
return trim($html);
8081
}

0 commit comments

Comments
 (0)