Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a54735

Browse filesBrowse files
bug #46221 [DomCrawler][VarDumper] Fix html-encoding emojis (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [DomCrawler][VarDumper] Fix html-encoding emojis | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46212 | License | MIT | Doc PR | - Commits ------- 26fbc96 [DomCrawler][VarDumper] Fix html-encoding emojis
2 parents 5f9b3ee + 26fbc96 commit 3a54735
Copy full SHA for 3a54735

File tree

3 files changed

+10
-3
lines changed
Filter options

3 files changed

+10
-3
lines changed

‎src/Symfony/Component/DomCrawler/Crawler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Crawler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,11 @@ private function convertToHtmlEntities(string $htmlContent, string $charset = 'U
12141214
set_error_handler(function () { throw new \Exception(); });
12151215

12161216
try {
1217-
return mb_encode_numericentity($htmlContent, [0x80, 0xFFFF, 0, 0xFFFF], $charset);
1217+
return mb_encode_numericentity($htmlContent, [0x80, 0x10FFFF, 0, 0x1FFFFF], $charset);
12181218
} catch (\Exception|\ValueError $e) {
12191219
try {
12201220
$htmlContent = iconv($charset, 'UTF-8', $htmlContent);
1221-
$htmlContent = mb_encode_numericentity($htmlContent, [0x80, 0xFFFF, 0, 0xFFFF], 'UTF-8');
1221+
$htmlContent = mb_encode_numericentity($htmlContent, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8');
12221222
} catch (\Exception|\ValueError $e) {
12231223
}
12241224

‎src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ public function testHtml()
379379
$this->assertSame('my value', $this->createTestCrawler(null)->filterXPath('//ol')->html('my value'));
380380
}
381381

382+
public function testEmojis()
383+
{
384+
$crawler = $this->createCrawler('<body><p>Hey 👋</p></body>');
385+
386+
$this->assertSame('<body><p>Hey 👋</p></body>', $crawler->html());
387+
}
388+
382389
public function testExtract()
383390
{
384391
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');

‎src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ protected function dumpLine($depth, $endOfValue = false)
978978
}
979979
$this->lastDepth = $depth;
980980

981-
$this->line = mb_encode_numericentity($this->line, [0x80, 0xFFFF, 0, 0xFFFF], 'UTF-8');
981+
$this->line = mb_encode_numericentity($this->line, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8');
982982

983983
if (-1 === $depth) {
984984
AbstractDumper::dumpLine(0);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.