From 74bcc33fdbcc273f196c42ffb60f0f11a067f7e9 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2023 11:35:34 +0000 Subject: [PATCH] Support for feeds that follow the ATOM 0.3 specification --- src/Protocol/ActivityNamespace.php | 6 ++++++ src/Protocol/Feed.php | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityNamespace.php b/src/Protocol/ActivityNamespace.php index 2301d547f..bcbf5b403 100644 --- a/src/Protocol/ActivityNamespace.php +++ b/src/Protocol/ActivityNamespace.php @@ -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 */ diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index bfb744838..f31513b23 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -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#');