Skip to content

Commit e800eba

Browse files
committed
DomQuery:: fixed UTF-8 handling
1 parent fd9419b commit e800eba

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Framework/DomQuery.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public static function fromHtml(string $html): self
2424
$html = '<body>' . $html;
2525
}
2626

27+
$html = @mb_convert_encoding($html, 'HTML', 'UTF-8'); // @ - deprecated
28+
2729
// parse these elements as void
2830
$html = preg_replace('#<(keygen|source|track|wbr)(?=\s|>)((?:"[^"]*"|\'[^\']*\'|[^"\'>])*+)(?<!/)>#', '<$1$2 />', $html);
2931

tests/Framework/DomQuery.fromHtml.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ Assert::true($q->has('script[type]'));
3838

3939
$q = @DomQuery::fromHtml('<custom-element></custom-element>');
4040
Assert::true($q->has('custom-element'));
41+
42+
43+
$q = DomQuery::fromHtml('<p>žluťoučký</p>');
44+
Assert::same('žluťoučký', (string) $q->find('p')[0]);

0 commit comments

Comments
 (0)