You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/09/23 02:23:46 UTC
svn commit: r291049 - in /beehive/trunk/netui:
src/compiler-core/org/apache/beehive/netui/compiler/model/
test/webapps/drt/coreWeb/miniTests/escapeXmlChars/
test/webapps/drt/testRecorder/config/ test/webapps/drt/testRecorder/tests/
Author: rich
Date: Thu Sep 22 17:23:29 2005
New Revision: 291049
URL: http://svn.apache.org/viewcvs?rev=291049&view=rev
Log:
Merging in the branches/v1/final fix for http://issues.apache.org/jira/browse/BEEHIVE-949 : netui compiler does not encode strings in validation config files
tests: bvt in netui (WinXP)
BB: bvt in netui (linux)
Added:
beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/
- copied from r290880, beehive/branches/v1/final/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/
beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/Controller.java (props changed)
- copied unchanged from r290880, beehive/branches/v1/final/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/Controller.java
beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/index.jsp (props changed)
- copied unchanged from r290880, beehive/branches/v1/final/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/index.jsp
beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/success.jsp (props changed)
- copied unchanged from r290880, beehive/branches/v1/final/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/success.jsp
beehive/trunk/netui/test/webapps/drt/testRecorder/tests/EscapeXmlChars.xml (props changed)
- copied unchanged from r290880, beehive/branches/v1/final/netui/test/webapps/drt/testRecorder/tests/EscapeXmlChars.xml
Modified:
beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java
beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Modified: beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java?rev=291049&r1=291048&r2=291049&view=diff
==============================================================================
--- beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java (original)
+++ beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java Thu Sep 22 17:23:29 2005
@@ -99,7 +99,7 @@
* a TransformerFactory.
*/
public void simpleFastWrite(Writer out)
- throws IOException
+ throws IOException, XmlModelWriterException
{
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
@@ -188,14 +188,15 @@
{
doIndent(out, indent);
out.write('<');
- out.write(element.getTagName());
+ String tagName = element.getTagName();
+ out.write(tagName);
NamedNodeMap attrs = element.getAttributes();
for (int i = 0, len = attrs.getLength(); i < len; ++i) {
Node attr = attrs.item(i);
out.write(' ');
out.write(attr.getNodeName());
out.write("=\"");
- out.write(attr.getNodeValue());
+ filterValue(out, attr.getNodeValue(), true);
out.write('"');
}
@@ -204,9 +205,9 @@
int childCount = children.getLength();
if (textContent != null) {
out.write('>');
- out.write(textContent);
+ filterValue(out, textContent, false);
out.write("</");
- out.write(element.getTagName());
+ out.write(tagName);
out.write(">\n");
} else if (childCount > 0) {
out.write(">\n");
@@ -223,7 +224,7 @@
}
doIndent(out, indent);
out.write("</");
- out.write(element.getTagName());
+ out.write(tagName);
out.write(">\n");
}
else {
@@ -236,7 +237,31 @@
{
doIndent(out, indent);
out.write("<!--");
- out.write(comment.getNodeValue());
+ filterValue(out, comment.getNodeValue(), false);
out.write("-->\n");
+ }
+
+ private static void filterValue(Writer writer, String value, boolean filterQuote)
+ throws IOException {
+ for (int i = 0; i < value.length(); ++i) {
+ char c = value.charAt(i);
+ switch (c) {
+ case '<':
+ writer.write("<");
+ break;
+ case '>':
+ writer.write(">");
+ break;
+ case '&':
+ writer.write("&");
+ break;
+ default:
+ if (filterQuote && c == '"') {
+ writer.write(""");
+ } else {
+ writer.write(c);
+ }
+ }
+ }
}
}
Propchange: beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/Controller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/escapeXmlChars/success.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?rev=291049&r1=291048&r2=291049&view=diff
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original)
+++ beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Thu Sep 22 17:23:29 2005
@@ -3692,6 +3692,19 @@
</features>
</test>
<test>
+ <name>EscapeXmlChars</name>
+ <description>Test to ensure that trouble-causing XML characters are properly escaped in XML attributes and XML text values, in generated Struts and Validator config files.</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>bvt.struts11</category>
+ </categories>
+ <features>
+ <feature>Validation</feature>
+ <feature>Action</feature>
+ </features>
+ </test>
+ <test>
<name>EventReporter</name>
<description>Test to ensure that the right Page Flow events get reported.</description>
<webapp>coreWeb</webapp>
Propchange: beehive/trunk/netui/test/webapps/drt/testRecorder/tests/EscapeXmlChars.xml
------------------------------------------------------------------------------
svn:eol-style = native