applied patch by Markus Döring (fixes #158)

This commit is contained in:
Martin Kurz 2013-10-07 23:35:37 +02:00
parent 40e916a34b
commit 9d8dfbaf26
3 changed files with 1618 additions and 12 deletions

View file

@ -16,8 +16,6 @@
*/ */
package com.sun.syndication.io.impl; package com.sun.syndication.io.impl;
import java.util.List;
import org.jdom2.Document; import org.jdom2.Document;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
@ -47,9 +45,9 @@ public class RSS10Parser extends RSS090Parser {
* Indicates if a JDom document is an RSS instance that can be parsed with * Indicates if a JDom document is an RSS instance that can be parsed with
* the parser. * the parser.
* <p/> * <p/>
* It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and RSS * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
* ("http://purl.org/rss/1.0/") namespaces being defined in the root * namespace being defined in the root element and for the RSS 1.0
* element. * ("http://purl.org/rss/1.0/") namespace in the channel element.
* *
* @param document document to check if it can be parsed with this parser * @param document document to check if it can be parsed with this parser
* implementation. * implementation.
@ -61,17 +59,14 @@ public class RSS10Parser extends RSS090Parser {
final Element rssRoot = document.getRootElement(); final Element rssRoot = document.getRootElement();
final Namespace defaultNS = rssRoot.getNamespace(); final Namespace defaultNS = rssRoot.getNamespace();
final List<Namespace> additionalNSs = rssRoot.getAdditionalNamespaces();
ok = defaultNS != null && defaultNS.equals(getRDFNamespace()); ok = defaultNS != null && defaultNS.equals(getRDFNamespace());
if (ok) { if (ok) {
if (additionalNSs == null) { // now also test if the channel element exists with the right
// namespace
final Element channel = rssRoot.getChild("channel", getRSSNamespace());
if (channel == null) {
ok = false; ok = false;
} else {
ok = false;
for (int i = 0; !ok && i < additionalNSs.size(); i++) {
ok = getRSSNamespace().equals(additionalNSs.get(i));
}
} }
} }
return ok; return ok;

View file

@ -0,0 +1,20 @@
package com.sun.syndication.unittest.issues;
import com.sun.syndication.unittest.FeedTest;
/**
* Test for #161: No source element in RSS 2.0 items.
* @author Martin Kurz
*
*/
public class Issue158Test extends FeedTest {
public Issue158Test() {
super("rss_1.0-ns-on-channel.xml");
}
public void testSyndFeed() throws Exception {
assertEquals("rss_1.0", this.getCachedSyndFeed().getFeedType());
}
}

File diff suppressed because one or more lines are too long