Browse Source

Use correct method to fetch IDs

master
J. King 4 years ago
parent
commit
ce6a5f9a79
  1. 6
      lib/Parser/XML/Primitives/Construct.php
  2. 13
      tests/cases/XML/feed-atom.yaml
  3. 13
      tests/cases/XML/feed-rss1.yaml
  4. 12
      tests/cases/XML/feed-rss2.yaml

6
lib/Parser/XML/Primitives/Construct.php

@ -120,7 +120,7 @@ trait Construct {
/** Primitive to fetch an Atom feed/entry identifier */
protected function getIdAtom(): ?string {
return $this->fetchString("atom:id");
return $this->fetchString("atom:id", ".+");
}
/** Primitive to fetch an RSS feed/entry identifier
@ -128,12 +128,12 @@ trait Construct {
* Using RSS' <guid> for feed identifiers is non-standard, but harmless
*/
protected function getIdRss2(): ?string {
return $this->fetchString("guid");
return $this->fetchString("guid", ".+");
}
/** Primitive to fetch a Dublin Core feed/entry identifier */
protected function getIdDC(): ?string {
return $this->fetchString("dc:identifier");
return $this->fetchString("dc:identifier", ".+");
}
/** Primitive to fetch a collection of authors associated with a feed/entry via Dublin Core */

13
tests/cases/XML/feed-atom.yaml

@ -26,3 +26,16 @@ Atom ID with whitespace:
format: atom
version: '1.0'
id: 'http://example.com/'
Bogus ID before good:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<id/>
<id>http://example.com/</id>
</feed>
output:
format: atom
version: '1.0'
id: 'http://example.com/'

13
tests/cases/XML/feed-rss1.yaml

@ -39,6 +39,19 @@ DC ID:
version: '1.0'
id: 'http://example.com/'
Bogus DC ID before good:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<dc:identifier/>
<dc:identifier>http://example.com/</dc:identifier>
</channel>
</rdf:RDF>
output:
format: rdf
version: '1.0'
id: 'http://example.com/'
DC ID with whitespace:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">

12
tests/cases/XML/feed-rss2.yaml

@ -38,6 +38,18 @@ Root GUID: # Any elements on the RSS2 root element should be ignored
output:
format: rss
Bogus GUID before good:
input: >
<rss>
<channel>
<guid/>
<guid>http://example.com/</guid>
</channel>
</rss>
output:
format: rss
id: 'http://example.com/'
Schedule interval 1:
input: >
<rss><channel>

Loading…
Cancel
Save