Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#234 Implemented possibility to allow doctype declarations using fetcher #275

Merged
merged 1 commit into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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