diff --git a/.classpath b/.classpath
index 06f0f30..25e83a6 100644
--- a/.classpath
+++ b/.classpath
@@ -18,8 +18,9 @@
-
+
+
diff --git a/lib/commons-lang3-3.11-sources.jar b/lib/commons-lang3-3.11-sources.jar
new file mode 100644
index 0000000..68cad64
Binary files /dev/null and b/lib/commons-lang3-3.11-sources.jar differ
diff --git a/lib/commons-lang3-3.11.jar b/lib/commons-lang3-3.11.jar
new file mode 100644
index 0000000..bbaa8a6
Binary files /dev/null and b/lib/commons-lang3-3.11.jar differ
diff --git a/lib/commons-lang3-3.7-sources.jar b/lib/commons-lang3-3.7-sources.jar
deleted file mode 100644
index a83c661..0000000
Binary files a/lib/commons-lang3-3.7-sources.jar and /dev/null differ
diff --git a/lib/commons-lang3-3.7.jar b/lib/commons-lang3-3.7.jar
deleted file mode 100644
index f37ded6..0000000
Binary files a/lib/commons-lang3-3.7.jar and /dev/null differ
diff --git a/lib/commons-text-1.9-sources.jar b/lib/commons-text-1.9-sources.jar
new file mode 100644
index 0000000..a636e92
Binary files /dev/null and b/lib/commons-text-1.9-sources.jar differ
diff --git a/lib/commons-text-1.9.jar b/lib/commons-text-1.9.jar
new file mode 100644
index 0000000..cc0c690
Binary files /dev/null and b/lib/commons-text-1.9.jar differ
diff --git a/src/fr/devinsy/xidyn/data/TagDataManager.java b/src/fr/devinsy/xidyn/data/TagDataManager.java
index 9e27a10..9773966 100644
--- a/src/fr/devinsy/xidyn/data/TagDataManager.java
+++ b/src/fr/devinsy/xidyn/data/TagDataManager.java
@@ -19,6 +19,7 @@
package fr.devinsy.xidyn.data;
import fr.devinsy.xidyn.presenters.DomPresenterCore;
+import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class TagDataManager.
@@ -659,6 +660,57 @@ public class TagDataManager
idData.setContent(content);
}
+ /**
+ * Sets the escaped content.
+ *
+ * @param id
+ * the id
+ * @param line
+ * the line
+ * @param content
+ * the content
+ */
+ public void setEscapedContent(final String id, final int line, final String content)
+ {
+ SimpleTagData tag = this.getIdData(id, line);
+
+ tag.setContent(XidynUtils.escapeXmlBlank(content));
+ }
+
+ /**
+ * Sets the escaped content.
+ *
+ * @param id
+ * the id
+ * @param line
+ * the line
+ * @param column
+ * the column
+ * @param content
+ * the content
+ */
+ public void setEscapedContent(final String id, final int line, final String column, final String content)
+ {
+ SimpleTagData tag = this.getIdData(id, line, column);
+
+ tag.setContent(XidynUtils.escapeXmlBlank(content));
+ }
+
+ /**
+ * Sets the escaped content.
+ *
+ * @param id
+ * the id
+ * @param content
+ * the content
+ */
+ public void setEscapedContent(final String id, final String content)
+ {
+ SimpleTagData idData = this.getIdData(id);
+
+ idData.setContent(XidynUtils.escapeXmlBlank(content));
+ }
+
/**
* Sets the iteration strategy.
*
diff --git a/src/fr/devinsy/xidyn/utils/XidynUtils.java b/src/fr/devinsy/xidyn/utils/XidynUtils.java
index f4f00c8..8afcb21 100644
--- a/src/fr/devinsy/xidyn/utils/XidynUtils.java
+++ b/src/fr/devinsy/xidyn/utils/XidynUtils.java
@@ -34,6 +34,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.validation.Schema;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -131,7 +133,8 @@ public class XidynUtils
if (errorHandler.hasError())
{
// Most time, error is (with StringPresenter):
- // "Error at line 1 : Document root element "html", must match DOCTYPE root
+ // "Error at line 1 : Document root element "html", must match
+ // DOCTYPE root
// "null".
// Error at line 1 : Document is invalid: no grammar found.
// We ignore it. STU
@@ -210,7 +213,8 @@ public class XidynUtils
if (errorHandler.hasError())
{
// Most time, error is (with StringPresenter):
- // "Error at line 1 : Document root element "html", must match DOCTYPE root
+ // "Error at line 1 : Document root element "html", must match
+ // DOCTYPE root
// "null".
// Error at line 1 : Document is invalid: no grammar found.
// We ignore it. STU
@@ -243,6 +247,30 @@ public class XidynUtils
return result;
}
+ /**
+ * Escape xml blank.
+ *
+ * @param source
+ * the source
+ * @return the string
+ */
+ public static String escapeXmlBlank(final String source)
+ {
+ String result;
+
+ if (StringUtils.isBlank(source))
+ {
+ result = "";
+ }
+ else
+ {
+ result = StringEscapeUtils.escapeXml11(source);
+ }
+
+ //
+ return result;
+ }
+
/**
* Good estimation of the target length able to optimize performance.
*
@@ -315,11 +343,12 @@ public class XidynUtils
/**
* This method extracts the string before the html tag.
*
- * A possible way is to use pattern searching for $(.*)<html>.*^.
- * But if there is no html tag, all the source is read for nothing.
+ * A possible way is to use pattern searching for
+ * $(.*)<html>.*^. But if there is no html tag, all the
+ * source is read for nothing.
*
- * A best way is to analyze each < while it is a XML tag or a DOCTYPE tag or
- * the <HTML> tag.
+ * A best way is to analyze each < while it is a XML tag or a DOCTYPE tag
+ * or the <HTML> tag.
*
* Uses cases:
*
@@ -330,8 +359,8 @@ public class XidynUtils
*
* @param source
* the source
- * @return the string before the html tag or null if no html tag
- * found. So, "" if there is a html tag without doctype.
+ * @return the string before the html tag or null if no html
+ * tag found. So, "" if there is a html tag without doctype.
*/
public static String extractDoctype(final String source)
{
@@ -788,8 +817,8 @@ public class XidynUtils
}
/**
- * Any ampersand lt;, ampersand gt; and ampersand amp; sequences in text nodes
- * get read in as symbols. This method converts them back to entities.
+ * Any ampersand lt;, ampersand gt; and ampersand amp; sequences in text
+ * nodes get read in as symbols. This method converts them back to entities.
*
* @param source
* String that is to have the entities restored..
diff --git a/test/fr/devinsy/xidyn/data/TagDataManagerTest.java b/test/fr/devinsy/xidyn/data/TagDataManagerTest.java
index 24e0738..7827c0a 100644
--- a/test/fr/devinsy/xidyn/data/TagDataManagerTest.java
+++ b/test/fr/devinsy/xidyn/data/TagDataManagerTest.java
@@ -255,4 +255,25 @@ public class TagDataManagerTest
Assertions.assertThat(target).isEqualTo(goal);
}
+
+ /**
+ * Test set escaped content.
+ *
+ * @throws Exception
+ * the exception
+ */
+ @Test
+ public void testSetEscapedContent01() throws Exception
+ {
+ String source = "n/a";
+
+ TagDataManager data = new TagDataManager();
+ data.setEscapedContent("foo", "foo");
+
+ String target = PresenterUtils.dynamize(source, data).toString();
+
+ String goal = "<b>foo</b>";
+
+ Assertions.assertThat(target).isEqualTo(goal);
+ }
}