From 9642e11aac22ad1790fcafcc6973605581bb4cb5 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Thu, 7 Jul 2011 03:44:22 +0000 Subject: [PATCH] Making unescapeHtml _NOT_ escape unfinished numeric entities by default (it ignores them); however adding options that will fire an exception or unescape the numeric entity. LANG-710 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1143641 13f79535-47bb-0310-9956-ffa450edef68 --- .../translate/NumericEntityUnescaper.java | 50 ++++++++++++++++++- .../translate/NumericEntityUnescaperTest.java | 24 ++++++++- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java index d4bd7fd50..0e5e36d3e 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java @@ -18,6 +18,8 @@ package org.apache.commons.lang3.text.translate; import java.io.IOException; import java.io.Writer; +import java.util.Arrays; +import java.util.EnumSet; /** * Translate XML numeric entities of the form &#[xX]?\d+;? to @@ -30,6 +32,41 @@ import java.io.Writer; */ public class NumericEntityUnescaper extends CharSequenceTranslator { + public static enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon } + + // TODO?: Create an OptionsSet class to hide some of the conditional logic below + private final EnumSet