On 6 July 2015 at 14:15, bugzi...@apache.org wrote:
Mark Thomas ma...@apache.org changed:
What|Removed |Added
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #4 from Mark Thomas ma...@apache.org ---
JSP documents have to be well-formed XML. If you use tags from another
namespace then there is an assumption that they follow the rules for XML.
If
they don't then you'll need to work-around it. The approach Chris suggests
is
probably the easiest in this case but you can also use CDATA blocks if you
wish.
I was discussing this over on the user mailing list (
http://mail-archives.apache.org/mod_mbox/tomcat-users/201508.mbox/%3ccadaechwxdqy50jgdzfo43fzeox6zvkab27zejamvmrhjwyu...@mail.gmail.com%3E)
and have put together a patch which addresses the issue.
Since an empty body is valid XML, the patch changes Generator so that it
outputs empty bodies instead of self closing tags.
I've attached the patch to the email so that others can get an idea of what
I'm doing.
The file 58095a.txt is the actual patch. It needed changes to one of the
test cases that assumed self-closing tags as part of what it was testing.
I've also attached 58095b.txt (which doesn't necessarily need to be
committed) that exercises the change in the JSP examples webapp.
If there is interest then I can re-open this bug and attach the patch
properly.
Thanks for your consideration.
Kevin.
Index: java/org/apache/jasper/compiler/Generator.java
===
--- java/org/apache/jasper/compiler/Generator.java (revision 1696322)
+++ java/org/apache/jasper/compiler/Generator.java (working copy)
@@ -1926,21 +1926,18 @@
}
}
-if (n.getBody() != null) {
-out.println(\););
+// Close the begin tag
+out.println(\););
-// Visit tag body
-visitBody(n);
+// Visit tag body
+visitBody(n);
-/*
- * Write end tag
- */
-out.printin(out.write(\/);
-out.print(n.getQName());
-out.println(\););
-} else {
-out.println(/\););
-}
+/*
+ * Write end tag
+ */
+out.printin(out.write(\/);
+out.print(n.getQName());
+out.println(\););
n.setEndJavaLine(out.getJavaLine());
}
Index: test/org/apache/jasper/compiler/TestParser.java
===
--- test/org/apache/jasper/compiler/TestParser.java (revision 1696322)
+++ test/org/apache/jasper/compiler/TestParser.java (working copy)
@@ -279,24 +279,24 @@
// NOTE: The expected values must themselves be \ escaped below
Assert.assertTrue(result, result.contains(01a\\?resize01a));
Assert.assertTrue(result, result.contains(01bx\\?resize01b));
-Assert.assertTrue(result, result.contains(set
data-value=\02a?resize02a\/));
-Assert.assertTrue(result, result.contains(set
data-value=\02bx?resize02b\/));
-Assert.assertTrue(result, result.contains(set
data-value=\03a\\?resize03a\/));
-Assert.assertTrue(result, result.contains(set
data-value=\03bx\\?resize03b\/));
+Assert.assertTrue(result, result.contains(set
data-value=\02a?resize02a\/set));
+Assert.assertTrue(result, result.contains(set
data-value=\02bx?resize02b\/set));
+Assert.assertTrue(result, result.contains(set
data-value=\03a\\?resize03a\/set));
+Assert.assertTrue(result, result.contains(set
data-value=\03bx\\?resize03b\/set));
Assert.assertTrue(result, result.contains(04a\\?resize04a/));
Assert.assertTrue(result, result.contains(04bx\\?resize04b/));
-Assert.assertTrue(result, result.contains(set
data-value=\05a\\$${amp;\/));
-Assert.assertTrue(result, result.contains(set
data-value=\05b\\$${amp;2\/));
-Assert.assertTrue(result, result.contains(set
data-value=\05c\\##{gt;hellolt;\/));
-Assert.assertTrue(result, result.contains(05x:set
data-value=\\/));
-Assert.assertTrue(result, result.contains(set
xmlns:foo=\urn:06a\\bar\\baz\/));
-Assert.assertTrue(result, result.contains(07a:set
data-value=\\\?resize\/));
-Assert.assertTrue(result, result.contains(07b:set
data-content=\\\?resize=.+\/));
-Assert.assertTrue(result, result.contains(07c:set
data-content=\\\?resize=.+\/));
-Assert.assertTrue(result, result.contains(07d:set
data-content=\false\/));
-Assert.assertTrue(result, result.contains(07e:set
data-content=\false\/));
-