aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php11
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;