1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
protected String encod(String str) {
if (str == null) {
return "";
}
Whitelist whitelist = new Whitelist();
for (String tag : Datas.ARRAYTAGENCOD) {
whitelist.addTags(tag);
}
whitelist.addAttributes("a", "href");
whitelist.addAttributes("img", "src", "width", "height");
whitelist.addEnforcedAttribute("a", "rel", "nofollow");
whitelist.addEnforcedAttribute("a", "target", "_blank");
whitelist.addProtocols("a", "href", "ftp", "http", "https");
str = Jsoup.clean(str, whitelist);
Matcher matcher;
Pattern pattern;
String replace;
pattern = Pattern.compile("&");
matcher = pattern.matcher(str);
replace = "&";
str = matcher.replaceAll(replace);
return str;
}
protected String decod(String str) {
if (str == null) {
str = "";
}
Matcher matcher;
Pattern pattern;
String replace;
pattern = Pattern.compile("&");
matcher = pattern.matcher(str);
replace = "&";
str = matcher.replaceAll(replace);
return str;
} |
Partager