Skip to content

Commit

Permalink
fix: PHP 8.2 deprecation warning for mb_convert_encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
shvlv committed Feb 27, 2024
1 parent 9af2c19 commit f842c30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/OutputFilter/AttributesOutputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __invoke(string $html, Asset $asset): string
$doc = new \DOMDocument();
libxml_use_internal_errors(true);
@$doc->loadHTML(
mb_encode_numericentity($html, [0x80, 0xFFFF, 0, 0xFFFF], "UTF-8"),
mb_encode_numericentity($html, [0x80, 0x10FFFF, 0, ~0], "UTF-8"),
LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD
);
libxml_clear_errors();
Expand All @@ -60,7 +60,7 @@ public function __invoke(string $html, Asset $asset): string
$this->applyAttributes($script, $attributes);
}

return $this->removeRootElement($doc->saveHTML());
return $this->removeRootElement(html_entity_decode($doc->saveHTML()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,10 @@ public function provideRenderWithInlineScripts(): \Generator
$multiLineJs,
$multiLineJs,
];

yield 'before and after multibyte line' => [
'<script>(function(){ console.log("Lösungen ї 𠀋"); })();</script>',
'<script>(function(){ console.log("Lösungen ї 𠀋"); })();</script>',
];
}
}

0 comments on commit f842c30

Please sign in to comment.