Skip to content

Commit

Permalink
#234 Implemented possibility to allow doctype declarations using fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickGotthard committed Mar 1, 2016
1 parent 10d6b12 commit f9dedf8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
11 changes: 11 additions & 0 deletions rome-fetcher/src/main/java/com/rometools/fetcher/FeedFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,15 @@ public interface FeedFetcher {
* corresponding wireEntry property set.
*/
void setPreserveWireFeed(boolean preserveWireFeed);

/**
* In ROME 1.5.1 we fixed a security vulnerability by disallowing Doctype declarations by default.
* This change breaks the compatibility with at least RSS 0.91N because it requires a Doctype declaration.
* You are able to allow Doctype declarations again with this property. You should only activate it
* when the feeds that you process are absolutely trustful.
*
* @param allowDoctypes true when Doctype declarations should be allowed again, false otherwise
*/
void setAllowDoctypes(boolean allowDoctypes);

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract class AbstractFeedFetcher implements FeedFetcher {
private String userAgent;
private boolean usingDeltaEncoding;
private boolean preserveWireFeed;
private boolean allowDoctypes = false;

public AbstractFeedFetcher() {

Expand Down Expand Up @@ -222,4 +223,13 @@ public void setPreserveWireFeed(final boolean preserveWireFeed) {
this.preserveWireFeed = preserveWireFeed;
}

public boolean isAllowDoctypes() {
return allowDoctypes;
}

@Override
public void setAllowDoctypes(boolean allowDoctypes) {
this.allowDoctypes = allowDoctypes;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ private SyndFeed retrieveFeed(final String urlStr, final HttpMethod method) thro

final SyndFeedInput syndFeedInput = new SyndFeedInput();
syndFeedInput.setPreserveWireFeed(isPreserveWireFeed());
syndFeedInput.setAllowDoctypes(isAllowDoctypes());

return syndFeedInput.build(reader);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,6 @@ private SyndFeed readSyndFeedFromStream(final InputStream inputStream, final URL
is = new BufferedInputStream(inputStream);
}

// InputStreamReader reader = new InputStreamReader(is,
// ResponseHandler.getCharacterEncoding(connection));

// SyndFeedInput input = new SyndFeedInput();

final XmlReader reader;
if (connection.getHeaderField("Content-Type") != null) {
reader = new XmlReader(is, connection.getHeaderField("Content-Type"), true);
Expand All @@ -294,6 +289,7 @@ private SyndFeed readSyndFeedFromStream(final InputStream inputStream, final URL

final SyndFeedInput syndFeedInput = new SyndFeedInput();
syndFeedInput.setPreserveWireFeed(isPreserveWireFeed());
syndFeedInput.setAllowDoctypes(isAllowDoctypes());

return syndFeedInput.build(reader);

Expand Down

0 comments on commit f9dedf8

Please sign in to comment.