Merge pull request #13094 from annando/atom03

Support for feeds that follow the ATOM 0.3 specification
This commit is contained in:
Hypolite Petovan 2023-05-06 09:43:11 -04:00 committed by GitHub
commit d196fbbd54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -145,6 +145,12 @@ final class ActivityNamespace
*/
const ATOM1 = 'http://www.w3.org/2005/Atom';
/**
* This namespace is used for the (deprecated) Atom 0.3 specification
* @var string
*/
const ATOM03 = 'http://purl.org/atom/ns#';
/**
* @var string
*/

View file

@ -92,7 +92,12 @@ class Feed
$doc = new DOMDocument();
@$doc->loadXML($xml);
$xpath = new DOMXPath($doc);
$xpath->registerNamespace('atom', ActivityNamespace::ATOM1);
if (strpos($xml, ActivityNamespace::ATOM03) && !strpos($xml, ActivityNamespace::ATOM1)) {
$xpath->registerNamespace('atom', ActivityNamespace::ATOM03);
} else {
$xpath->registerNamespace('atom', ActivityNamespace::ATOM1);
}
$xpath->registerNamespace('dc', 'http://purl.org/dc/elements/1.1/');
$xpath->registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');