Skip to content

Commit af5ed22

Browse files
committed
added warn when unicode is wrong
1 parent 00af6c3 commit af5ed22

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • dbptk-model/src/main/java/com/databasepreservation/utils

dbptk-model/src/main/java/com/databasepreservation/utils/XMLUtils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
import javax.xml.xpath.XPathExpressionException;
2424
import javax.xml.xpath.XPathFactory;
2525

26+
import com.databasepreservation.model.reporters.ValidationReporter;
2627
import org.apache.commons.lang3.StringUtils;
2728
import org.apache.commons.text.translate.AggregateTranslator;
2829
import org.apache.commons.text.translate.CharSequenceTranslator;
2930
import org.apache.commons.text.translate.EntityArrays;
3031
import org.apache.commons.text.translate.LookupTranslator;
3132
import org.apache.commons.text.translate.UnicodeEscaper;
3233
import org.apache.commons.text.translate.UnicodeUnescaper;
34+
import org.slf4j.Logger;
35+
import org.slf4j.LoggerFactory;
3336
import org.w3c.dom.Document;
3437
import org.w3c.dom.Element;
3538
import org.w3c.dom.Node;
@@ -41,6 +44,7 @@
4144
* @author Bruno Ferreira <bferreira@keep.pt>
4245
*/
4346
public class XMLUtils {
47+
private static final Logger LOGGER = LoggerFactory.getLogger(XMLUtils.class);
4448
/**
4549
* Translator to escape characters according to the SIARD specification
4650
*/
@@ -87,8 +91,12 @@ public static String decode(String text) {
8791
if (text == null) {
8892
return null;
8993
}
94+
try {
95+
text = SIARD_UNESCAPE.translate(text);
96+
} catch (IllegalArgumentException e) {
97+
LOGGER.warn("Illegal unicode on: " + text);
98+
}
9099

91-
text = SIARD_UNESCAPE.translate(text);
92100
return text;
93101
}
94102

0 commit comments

Comments
 (0)