mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
strip down utf8 4-byte characters
This commit is contained in:
@@ -102,6 +102,7 @@ public class FeedUpdateService {
|
||||
|
||||
private String handleContent(String content) {
|
||||
if (StringUtils.isNotBlank(content)) {
|
||||
content = trimUnicodeSurrogateCharacters(content);
|
||||
Whitelist whitelist = Whitelist.relaxed();
|
||||
whitelist.addEnforcedAttribute("a", "target", "_blank");
|
||||
|
||||
@@ -114,4 +115,15 @@ public class FeedUpdateService {
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
private String trimUnicodeSurrogateCharacters(String text) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user