diff options
| author | 2024-12-10 13:48:30 +0100 | |
|---|---|---|
| committer | 2024-12-10 13:48:30 +0100 | |
| commit | 88eef9832b7325158a913e203846e5a57829f307 (patch) | |
| tree | c9a38ce08ff259042c9b148de560c6070d5579c8 /app/Models/Entry.php | |
| parent | 3dc997d43289b6b05bf4d729d83b5da57045fc6c (diff) | |
Fix regression CSS filter encoding (#7081)
fix Unicode of https://github.com/FreshRSS/FreshRSS/pull/7073
Plus optimisation of XPath by keeping it into a variable.
Diffstat (limited to 'app/Models/Entry.php')
| -rw-r--r-- | app/Models/Entry.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 9854da131..cccfac5e1 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -847,7 +847,8 @@ HTML; unset($xpath, $doc); $html = sanitizeHTML($html, $base); $doc = new DOMDocument(); - $doc->loadHTML($html, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING); + $utf8BOM = "\xEF\xBB\xBF"; + $doc->loadHTML($utf8BOM . $html, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING); $xpath = new DOMXPath($doc); $html = ''; @@ -855,11 +856,11 @@ HTML; $cssSelector = trim($cssSelector, ', '); $nodes = $xpath->query((new Gt\CssXPath\Translator($cssSelector, '//'))->asXPath()); if ($nodes != false) { - $path_entries_filter = $feed->attributeString('path_entries_filter') ?? ''; - $path_entries_filter = trim($path_entries_filter, ', '); + $path_entries_filter = trim($feed->attributeString('path_entries_filter') ?? ''); + $filter_xpath = $path_entries_filter === '' ? '' : (new Gt\CssXPath\Translator($path_entries_filter, 'descendant-or-self::'))->asXPath(); foreach ($nodes as $node) { - if ($path_entries_filter !== '') { - $filterednodes = $xpath->query((new Gt\CssXPath\Translator($path_entries_filter, 'descendant-or-self::'))->asXPath(), $node) ?: []; + if ($filter_xpath !== '') { + $filterednodes = $xpath->query($filter_xpath, $node) ?: []; foreach ($filterednodes as $filterednode) { if ($filterednode === $node) { continue 2; |
