Use RSS v2 parser by default

Changed RSS v2 parser to match any feed that has "rss" as root element.
This makes Rome more lenient when handling feeds that don't adhere to
the RSS spec, namely have the "version" attribute missing.
This commit is contained in:
mishako 2016-02-27 19:39:37 +01:00
parent 10d6b126a3
commit deb781924e
2 changed files with 12 additions and 1 deletions

View file

@ -51,7 +51,8 @@ public class RSS20Parser extends RSS094Parser {
@Override
public boolean isMyType(final Document document) {
return rootElementMatches(document) && versionMatches(document);
return rootElementMatches(document)
&& (versionMatches(document) || versionAbsent(document));
}
private boolean rootElementMatches(final Document document) {
@ -63,4 +64,8 @@ public class RSS20Parser extends RSS094Parser {
return (version != null)
&& version.getValue().trim().startsWith(getRSSVersion());
}
private boolean versionAbsent(final Document document) {
return document.getRootElement().getAttribute("version") == null;
}
}

View file

@ -44,4 +44,10 @@ public class RSS20ParserTest {
document.setRootElement(new Element("rss").setAttribute("version", "2.0test"));
assertTrue(parser.isMyType(document));
}
@Test
public void testIsMyTypeVersionAbsent() {
document.setRootElement(new Element("rss"));
assertTrue(parser.isMyType(document));
}
}