diff --git a/lib/composer.json b/lib/composer.json index db2801fb8..a647f4c87 100644 --- a/lib/composer.json +++ b/lib/composer.json @@ -14,7 +14,7 @@ "marienfressinaud/lib_opml": "0.5.1", "phpgt/cssxpath": "v1.3.0", "phpmailer/phpmailer": "6.10.0", - "simplepie/simplepie": "dev-freshrss#9a1c69be7d9dc2b766cef8697a2f1e88ab9a64e5" + "simplepie/simplepie": "dev-freshrss#f644950102ef4d4ab6e811db6ee9416d7151484a" }, "config": { "sort-packages": true, diff --git a/lib/simplepie/simplepie/src/Parser.php b/lib/simplepie/simplepie/src/Parser.php index d6bdadf07..5c748477e 100644 --- a/lib/simplepie/simplepie/src/Parser.php +++ b/lib/simplepie/simplepie/src/Parser.php @@ -111,11 +111,18 @@ class Parser implements RegistryAware $declaration = $this->registry->create(DeclarationParser::class, [substr($data, 5, $pos - 5)]); if ($declaration->parse()) { $data = substr($data, $pos + 2); - $data = 'version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . "\n" . $data; + $data = preg_replace('/^\\s*\\[\\]]*>\s*/', '', $data); // Strip DOCTYPE except if containing an [internal subset] + $data = 'version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . "\n" . + (preg_match('/^\\s*declare_html_entities()) . // Declare HTML entities only if no remaining DOCTYPE + $data; } else { $this->error_string = 'SimplePie bug! Please report this!'; return false; } + } else { + $data = preg_replace('/^\\s*\\[\\]]*>\s*/', '', $data); // Strip DOCTYPE except if containing an [internal subset] + $data = (preg_match('/^\\s*declare_html_entities()) . // Declare HTML entities only if no remaining DOCTYPE + $data; } $return = true; @@ -643,6 +650,13 @@ class Parser implements RegistryAware $this->data = ['child' => ['' => ['rss' => $rss]]]; return true; } + + private function declare_html_entities(): string + { + // This is required because the RSS specification says that entity-encoded + // html is allowed, but the xml specification says they must be declared. + return ' ]>'; + } } class_alias('SimplePie\Parser', 'SimplePie_Parser');