combine all characters stripping in one place

This commit is contained in:
Athou
2013-04-23 09:31:02 +02:00
parent 29b3b92b85
commit 8500589943
2 changed files with 5 additions and 18 deletions

View File

@@ -123,8 +123,7 @@ public class FeedRefreshWorker {
feed.setDisabledUntil(disabledUntil);
if (fetchedFeed != null) {
feed.setLink(FeedUtils.trimUnicodeSurrogateCharacters(fetchedFeed
.getLink()));
feed.setLink(fetchedFeed.getLink());
feed.setLastModifiedHeader(fetchedFeed.getLastModifiedHeader());
feed.setEtagHeader(fetchedFeed.getEtagHeader());
feedUpdateService.updateEntries(feed, fetchedFeed.getEntries());

View File

@@ -26,7 +26,6 @@ public class FeedUtils {
public static String handleContent(String content) {
if (StringUtils.isNotBlank(content)) {
content = trimUnicodeSurrogateCharacters(content);
Whitelist whitelist = Whitelist.relaxed();
whitelist.addEnforcedAttribute("a", "target", "_blank");
@@ -48,21 +47,10 @@ public class FeedUtils {
for (int i = 0; i < xml.length(); i++) {
char c = xml.charAt(i);
if (c >= 20 || c == 0x9 || c == 0xA || c == 0xD) {
sb.append(c);
}
}
return sb.toString();
}
public static String trimUnicodeSurrogateCharacters(String text) {
if (StringUtils.isBlank(text)) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if (!Character.isHighSurrogate(ch) && !Character.isLowSurrogate(ch)) {
sb.append(ch);
if (!Character.isHighSurrogate(c)
&& !Character.isLowSurrogate(c)) {
sb.append(c);
}
}
}
return sb.toString();