Skip to content

Commit

Permalink
Fixes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Oct 21, 2024
1 parent dcd459a commit d482cf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## Unreleased
### Fixed
- Fixed an issue where the `retconAutoAlt` filter didn't work as intended [#71](https://github.com/mmikkel/Retcon-Craft/issues/71)
- Fixed an issue where Retcon would convert UTF-8 non-breaking spaces to HTML entities, preventing filters like `retconRemoveEmpty` from working correctly in all cases [#70](https://github.com/mmikkel/Retcon-Craft/issues/70)

## 3.2.0 - 2024-06-28
### Improved
Expand Down
8 changes: 4 additions & 4 deletions src/library/RetconDom.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ class RetconDom
*/
public function __construct($html)
{
$html = (string)$html;
$libxmlUseInternalErrors = \libxml_use_internal_errors(true);
$content = \mb_convert_encoding($html, 'HTML-ENTITIES', Craft::$app->getView()->getTwig()->getCharset());
$html = str_replace("\xc2\xa0", ' ', (string)$html); // Make sure UTF-8 non-breaking spaces are replaced with regular spaces
$libxmlUseInternalErrors = libxml_use_internal_errors(true);
$content = mb_convert_encoding($html, 'HTML-ENTITIES', Craft::$app->getView()->getTwig()->getCharset());
$this->doc = new \DOMDocument();
$this->doc->loadHTML("<html><retcon>$content</retcon></html>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$this->crawler = new Crawler($this->doc);
$this->html5 = new HTML5([
'encode_entities' => false,
]);
\libxml_use_internal_errors($libxmlUseInternalErrors);
libxml_use_internal_errors($libxmlUseInternalErrors);
}

/**
Expand Down

0 comments on commit d482cf2

Please sign in to comment.