- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 27 Aug 2009 11:15:16 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/output
In directory hutz:/tmp/cvs-serv7872/src/org/w3c/unicorn/output
Modified Files:
Tag: dev2
XHTMLize.java EscapeXMLEntities.java
Log Message:
uses StringEscapeUtils.escapeXML() instead of custom EscapeXMLEntities function
Index: EscapeXMLEntities.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/Attic/EscapeXMLEntities.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- EscapeXMLEntities.java 11 Aug 2009 16:20:43 -0000 1.1.2.1
+++ EscapeXMLEntities.java 27 Aug 2009 11:15:13 -0000 1.1.2.2
@@ -1,23 +1,8 @@
package org.w3c.unicorn.output;
+import org.apache.commons.lang.StringEscapeUtils;
import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
-/**
- * Escape all XML Entities in the reference insertion. Specifically, the
- * following conversions are performed:
- * <DL>
- * <DT>&</DT>
- * <DD>&amp;</DD>
- * <DT><</DT>
- * <DD>&lt;</DD>
- * <DT>></DT>
- * <DD>&gt;</DD>
- * <DT>"</DT>
- * <DD>&quot;</DD>
- * </DL>
- *
- * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
- */
public class EscapeXMLEntities implements ReferenceInsertionEventHandler {
/**
@@ -25,16 +10,17 @@
*/
public Object referenceInsert(final String sUnused, final Object oValue) {
final String sValue = oValue.toString();
- return EscapeXMLEntities.escapeText(sValue);
+ return StringEscapeUtils.escapeXml(sValue);
}
-
+
+
/**
* Escape the provided text.
*
* @param sValue
* @return
*/
- public static String escapeText(final String sValue) {
+ /*public static String escapeText(final String sValue) {
final StringBuffer aStringBuffer = new StringBuffer(sValue.length());
final int iLength = sValue.length();
int iPosition = 0;
@@ -58,7 +44,7 @@
}
return aStringBuffer.toString();
- }
+ }*/
/**
* Transform the escape char into xml encoding
@@ -67,7 +53,7 @@
* char to transform
* @return same character in xml form
*/
- private static String escapeChar(final char c) {
+ /*private static String escapeChar(final char c) {
switch (c) {
case '<':
return "<";
@@ -79,7 +65,7 @@
return """;
}
return null;
- }
+ }*/
/**
* Returns the position of the next xml tag
@@ -90,7 +76,7 @@
* current position in the string
* @return position of the next tag
*/
- private static int nextPosition(final String s, final int iCurrentPosition) {
+ /*private static int nextPosition(final String s, final int iCurrentPosition) {
final int iLT = s.indexOf('<', iCurrentPosition);
final int iGT = s.indexOf('>', iCurrentPosition);
final int iAMP = s.indexOf('&', iCurrentPosition);
@@ -109,6 +95,6 @@
return iAMP;
}
return iQUOT;
- }
+ }*/
}
Index: XHTMLize.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/Attic/XHTMLize.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- XHTMLize.java 11 Aug 2009 16:20:43 -0000 1.1.2.1
+++ XHTMLize.java 27 Aug 2009 11:15:13 -0000 1.1.2.2
@@ -1,5 +1,6 @@
package org.w3c.unicorn.output;
+import org.apache.commons.lang.StringEscapeUtils;
import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
import org.w3c.unicorn.response.A;
import org.w3c.unicorn.response.Code;
@@ -42,7 +43,7 @@
Code code = (Code) oValue;
return insertCode(code);
}
- return EscapeXMLEntities.escapeText(oValue.toString());
+ return StringEscapeUtils.escapeXml(oValue.toString());
}
/**
@@ -54,12 +55,12 @@
*/
private Object insertA(final A aLink) {
String sResultat = "<a href=\""
- + EscapeXMLEntities.escapeText(aLink.getHref()) + "\">";
+ + StringEscapeUtils.escapeXml(aLink.getHref()) + "\">";
for (final Object oElement : aLink.getContent()) {
if (oElement instanceof Img) {
sResultat += insertImg((Img) oElement);
} else {
- sResultat += EscapeXMLEntities.escapeText(oElement.toString());
+ sResultat += StringEscapeUtils.escapeXml(oElement.toString());
}
}
sResultat += "</a>";
@@ -81,7 +82,7 @@
} else if (oElement instanceof Img) {
sResultat += insertImg((Img) oElement);
} else {
- sResultat += EscapeXMLEntities.escapeText(oElement.toString());
+ sResultat += StringEscapeUtils.escapeXml(oElement.toString());
}
}
sResultat += "</code>";
@@ -96,8 +97,8 @@
* @return the string containing the image tag
*/
private String insertImg(final Img aImage) {
- return "<img src=\"" + EscapeXMLEntities.escapeText(aImage.getSrc())
- + "\" alt=\"" + EscapeXMLEntities.escapeText(aImage.getAlt())
+ return "<img src=\"" + StringEscapeUtils.escapeXml(aImage.getSrc())
+ + "\" alt=\"" + StringEscapeUtils.escapeXml(aImage.getAlt())
+ "\"/>";
}
Received on Thursday, 27 August 2009 11:15:27 UTC