forked from Archives/Athou_commafeed
fix #113
This commit is contained in:
@@ -24,8 +24,9 @@ public class FeedUtils {
|
|||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String handleContent(String content) {
|
public static String handleContent(String content, String baseUri) {
|
||||||
if (StringUtils.isNotBlank(content)) {
|
if (StringUtils.isNotBlank(content)) {
|
||||||
|
baseUri = StringUtils.trimToEmpty(baseUri);
|
||||||
Whitelist whitelist = Whitelist.relaxed();
|
Whitelist whitelist = Whitelist.relaxed();
|
||||||
whitelist.addEnforcedAttribute("a", "target", "_blank");
|
whitelist.addEnforcedAttribute("a", "target", "_blank");
|
||||||
|
|
||||||
@@ -33,8 +34,9 @@ public class FeedUtils {
|
|||||||
whitelist.addAttributes("iframe", "src", "height", "width",
|
whitelist.addAttributes("iframe", "src", "height", "width",
|
||||||
"allowfullscreen", "frameborder");
|
"allowfullscreen", "frameborder");
|
||||||
|
|
||||||
content = Jsoup.clean(content, "", whitelist,
|
content = Jsoup.clean(content, baseUri, whitelist,
|
||||||
new OutputSettings().escapeMode(EscapeMode.base));
|
new OutputSettings().escapeMode(EscapeMode.base)
|
||||||
|
.prettyPrint(false));
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,13 @@ public class FeedUpdateService {
|
|||||||
FeedEntry foundEntry = findEntry(existingEntries, entry);
|
FeedEntry foundEntry = findEntry(existingEntries, entry);
|
||||||
|
|
||||||
if (foundEntry == null) {
|
if (foundEntry == null) {
|
||||||
|
String baseUri = feed.getLink();
|
||||||
FeedEntryContent content = entry.getContent();
|
FeedEntryContent content = entry.getContent();
|
||||||
|
|
||||||
content.setContent(FeedUtils.handleContent(content.getContent()));
|
content.setContent(FeedUtils.handleContent(
|
||||||
String title = FeedUtils.handleContent(content.getTitle());
|
content.getContent(), baseUri));
|
||||||
|
String title = FeedUtils.handleContent(content.getTitle(),
|
||||||
|
baseUri);
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
content.setTitle(title.substring(0,
|
content.setTitle(title.substring(0,
|
||||||
Math.min(2048, title.length())));
|
Math.min(2048, title.length())));
|
||||||
|
|||||||
Reference in New Issue
Block a user