[Yanel-commits] rev 23997 -
public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources
simon at wyona.com
simon at wyona.com
Wed Apr 25 10:53:18 CEST 2007
Author: simon
Date: 2007-04-25 10:53:15 +0200 (Wed, 25 Apr 2007)
New Revision: 23997
Modified:
public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java
Log:
fixes bug# 5095. thanks to josias!
Modified: public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java 2007-04-24 19:53:46 UTC (rev 23996)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java 2007-04-25 08:53:15 UTC (rev 23997)
@@ -70,7 +70,7 @@
}
}
}
- transformedXmlAsBuffer.append(" " + aName + "=\"" + aValue + "\"");
+ transformedXmlAsBuffer.append(" " + aName + "=\"" + replaceEntities(aValue) + "\"");
}
} else {
for(int i = 0; i < attrs.getLength(); i++) {
@@ -81,7 +81,7 @@
if(aValue.charAt(j) == '"') tmp.append(""");
else tmp.append(aValue.charAt(j));
}
- transformedXmlAsBuffer.append(" " + aName + "=\"" + tmp.toString() + "\"");
+ transformedXmlAsBuffer.append(" " + aName + "=\"" + replaceEntities(tmp.toString()) + "\"");
}
}
transformedXmlAsBuffer.append(">");
@@ -94,8 +94,21 @@
public void characters(char[] buf, int offset, int len) throws SAXException {
String s = new String(buf, offset, len);
- transformedXmlAsBuffer.append(s);
+ transformedXmlAsBuffer.append(replaceEntities(s));
}
+
+ /**
+ * Replaces some characters by their corresponding xml entities.
+ * @param str
+ * @return
+ */
+ private String replaceEntities(String str) {
+ str = str.replaceAll("<", "<");
+ str = str.replaceAll(">", ">");
+ str = str.replaceAll("'", "'");
+ str = str.replaceAll("\"", """);
+ return str;
+ }
private void setResultInputStream() {
this.byteArrayInputStream = new ByteArrayInputStream(transformedXmlAsBuffer.toString().getBytes());
More information about the Yanel-commits
mailing list