Dmbaturin has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/332050 )
Change subject: Fix support for {{{link}}} in Atom feeds. According to RFC4287, the <id> element conveys as "permanent, universally unique identifier for an entry or feed." It must be an RFC3987 IRI, which doesn't have to be, and often is not a URL. The URL in Atom feed ...................................................................... Fix support for {{{link}}} in Atom feeds. According to RFC4287, the <id> element conveys as "permanent, universally unique identifier for an entry or feed." It must be an RFC3987 IRI, which doesn't have to be, and often is not a URL. The URL in Atom feed is supposed to be in the href= attribute of the <link> tag. Since RSS feeds use <link> tag content rather than attribute for this, some fixup is necessary. Change-Id: If41c9874ece434df03a280b31c8e964abdba00f6 --- M RSSData.php M RSSParser.php 2 files changed, 15 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RSS refs/changes/50/332050/1 diff --git a/RSSData.php b/RSSData.php index 9ac81c5..aa3cb99 100644 --- a/RSSData.php +++ b/RSSData.php @@ -41,7 +41,21 @@ * mark up their RSS, some more precautions are * needed. */ - $bit[$name] = trim( $n->nodeValue ); + if( $name == "link" ) { + /** + * In Atom feeds, the URL is in the href= attribute + * of the <link> tag, while in RSS it's in the + * content of the <link> tag + */ + $href = $n->attributes->getNamedItem( "href" )->nodeValue; + if( !is_null( $href ) ) { + $bit[$name] = trim( $href ); + } else { + $bit[$name] = trim( $n->nodeValue ); + } + } else { + $bit[$name] = trim( $n->nodeValue ); + } } } $this->items[] = $bit; diff --git a/RSSParser.php b/RSSParser.php index 5d5759d..4374121 100644 --- a/RSSParser.php +++ b/RSSParser.php @@ -395,11 +395,6 @@ foreach ( array_keys( $item ) as $info ) { if ( $item[$info] != "" ) { switch ( $info ) { - // ATOM <id> elements and RSS <link> elements are item link urls - case 'id': - $txt = $this->sanitizeUrl( $item['id'] ); - $renderedItem = str_replace( '{{{link}}}', $txt, $renderedItem ); - break; case 'link': $txt = $this->sanitizeUrl( $item['link'] ); $renderedItem = str_replace( '{{{link}}}', $txt, $renderedItem ); -- To view, visit https://gerrit.wikimedia.org/r/332050 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If41c9874ece434df03a280b31c8e964abdba00f6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/RSS Gerrit-Branch: master Gerrit-Owner: Dmbaturin <dan...@baturin.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits