each of the following lines throws a NumberFormatException:
String test1 = HTMLEntities.unhtmlentities("&#;");
String test2 = HTMLEntities.unhtmlentities("&#x;");
String test3 = HTMLEntities.unhtmlentities("&#ab;");
the fix:
change
Integer iso;
to
Integer iso = null;
and change
if (entity.charAt(1) == '#') {
if (entity.charAt(2) == 'x') {
iso = new Integer(Integer.parseInt(entity.substring(3, entity.length() - 1), 16));
}
else {
iso = new Integer(entity.substring(2, entity.length() - 1));
}
} else {
to
if (entity.charAt(1) == '#') {
try {
if (entity.charAt(2) == 'x') {
iso = new Integer(Integer.parseInt(entity.substring(3, entity.length() - 1), 16));
}
else {
iso = new Integer(entity.substring(2, entity.length() - 1));
}
} catch (NumberFormatException e) {}
} else {