Skip to content

Commit 0098825

Browse files
mr-chetangemini1389
andcommitted
Handle null return from mb_ereg_replace in TextNode
Adds a check for null return value from mb_ereg_replace to throw a LogicalException when invalid encoding is encountered, improving error handling in text cleaning. https: //github.com/paquettg/pull/260 Co-Authored-By: Gemini_13 <[email protected]>
1 parent b95e0da commit 0098825

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/PHPHtmlParser/Dom/Node/TextNode.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public function __construct(string $text, $removeDoubleSpace = true)
5858
if ($replacedText === false) {
5959
throw new LogicalException('mb_ereg_replace returns false when attempting to clean white space from "' . $text . '".');
6060
}
61+
62+
if ($replacedText === null) {
63+
throw new LogicalException('mb_ereg_replace encountered an invalid encoding for "' . $text . '".');
64+
}
65+
6166
$text = $replacedText;
6267
}
6368

0 commit comments

Comments
 (0)