in doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java [307:346]
public static String unescapeHTML(String text, boolean xmlMode) {
if (text == null) {
return null;
}
String unescaped;
if (xmlMode) {
unescaped = StringEscapeUtils.unescapeXml(text);
} else {
// StringEscapeUtils.unescapeHtml4 returns entities it doesn't recognize unchanged
unescaped = StringEscapeUtils.unescapeHtml4(text);
}
String tmp = unescaped;
List<String> entities = new ArrayList<>();
while (true) {
int i = tmp.indexOf("&#x");
if (i == -1) {
break;
}
tmp = tmp.substring(i + 3);
if (tmp.indexOf(';') != -1) {
String entity = tmp.substring(0, tmp.indexOf(';'));
try {
Integer.parseInt(entity, 16);
entities.add(entity);
} catch (NumberFormatException e) {
// nop
}
}
}
for (String entity : entities) {
int codePoint = Integer.parseInt(entity, 16);
unescaped = StringUtils.replace(unescaped, "&#x" + entity + ";", new String(toChars(codePoint)));
}
return unescaped;
}