[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 Kevin Hale Boyes kcbo...@gmail.com changed: What|Removed |Added CC||kcbo...@gmail.com -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #7 from Kevin Hale Boyes kcbo...@gmail.com --- I've played around with basic.jspx from the examples webapp. If you recall, it sets the content-type to be application/xhtml+xml. When I add a script tag with an empty body the output gets the self-closing tag the page renders fine. My test was pretty limited given that I used one browser (chrome) for my testing. So, it seems that setting the content type may be a good solution when possible. As I was saying over on the user mailing list (http://mail-archives.apache.org/mod_mbox/tomcat-users/201508.mbox/%3ccadaechwxdqy50jgdzfo43fzeox6zvkab27zejamvmrhjwyu...@mail.gmail.com%3E) I'm in the middle of migrating a large (and fairly old) code base from weblogic to tomcat. The generator used by WL didn't collapse the empty script tags so it hadn't been a problem. It also allowed us to write some incorrect code that we've been cleaning up as we progress with the migration to tomcat. In response to the comments in this bug and my email to the user list, I've recently tried to change our application so that the content type is xhtml+xml but it was difficult and didn't work. It was easier in the end to change all of the empty script tags to have comments. We also found that empty div and span tags could cause problems so we've added comments to those as well. But that leaves us vulnerable. If a developer doesn't understand the issue and cleans up code then things will break. We've tried to make it clear by saying script//do not remove/script but that only goes so far. We also had to put in special cases to our minification process to not strip those comments. Finally, as a minor issue, it increases the size of the response going back to the client. I'm proposing a patch that works around those problems. It's a simple patch that will write out a closing tag when there is no body and we're producing text/html. If the content type is anything else it will continue to produce the self-closing tags. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #8 from Kevin Hale Boyes kcbo...@gmail.com --- Created attachment 33019 -- https://bz.apache.org/bugzilla/attachment.cgi?id=33019action=edit Patch -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: [Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
Kevin, On 8/17/15 5:27 PM, Kevin Hale Boyes wrote: On 6 July 2015 at 14:15, bugzi...@apache.org mailto:bugzi...@apache.org wrote: Mark Thomas ma...@apache.org mailto:ma...@apache.org changed: What|Removed |Added Resolution|--- |INVALID Status|NEW |RESOLVED --- Comment #4 from Mark Thomas ma...@apache.org mailto: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. If you want to propose this patch, please attach it to the BZ issue directly, rather than replying to the message on the dev list. FWIW, I'm -1 on this patch right now because it solves a problem that does not really exist: .jspx - application/xml+xhtml should support self-closing script tags and broken browsers should be fixed instead. If this patch were to be less widely effective (e.g. only for certain content-types, or able to be configured), I'd be happier with it. -chris signature.asc Description: OpenPGP digital signature
Re: [Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
On 17 August 2015 at 15:43, Christopher Schultz ch...@christopherschultz.net wrote: If you want to propose this patch, please attach it to the BZ issue directly, rather than replying to the message on the dev list. Do I need to re-open the bug?
Re: [Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
Kevin, On 8/17/15 5:48 PM, Kevin Hale Boyes wrote: On 17 August 2015 at 15:43, Christopher Schultz ch...@christopherschultz.net wrote: If you want to propose this patch, please attach it to the BZ issue directly, rather than replying to the message on the dev list. Do I need to re-open the bug? You can attach a proposed patch to a RESOLVED bug, whether you re-open it or not. As of this moment, you have two committers with negative opinions on this proposal, though I am willing to be convinced to change my position. Let's resume the conversation inside BZ. -chris signature.asc Description: OpenPGP digital signature
Re: [Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
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\/)); -
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #5 from jones...@oildex.com --- Thanks for the input. Regarding Content-Type: Jasper sets the content type in the generated source file by itself, i.e: response.setContentType(text/xml;charset=UTF-8); I havent been able to confirm if it even makes a difference... at this time we've been employing the workaround across many of our jsp documents. We have also similar found issues with a self-closing form tag. We worked around it the same way as above. Ideally, I suppose, it would be possible to instruct Jasper to not coalesce tags vs. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #6 from Christopher Schultz ch...@christopherschultz.net --- (In reply to jonesgav from comment #5) We have also similar found issues with a self-closing form tag. I'm pretty sure a form with no child elements is not legal anyway. We worked around it the same way as above. Ideally, I suppose, it would be possible to instruct Jasper to not coalesce tags vs. Or you could use .jsp instead of .jspx, right? They are slightly different beasts. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 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. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #3 from Christopher Schultz ch...@christopherschultz.net --- I'm not sure this is a Tomcat issue, but I'm not sure exactly how Tomcat does its XML parsing, etc. I know that I've seen this problem with other XML-oriented HTML-handling software as well. A specific case in point: Apache Cocoon will take a script/script pair in an XSLT and generate script/ in the output. We have to use the same tricks like scriptxsl:commentboo!/xsl:comment/script in order to prevent the XML serializer from coalescing the tags together. The problem is likely to be that the XML serializer doesn't realize that there are certain HTML tags that cannot be self-closing (and script is the only one I know of of-hand). As far as XML is concerned, script/script (with no child elements) is equivalent to script/, so this behavior is completely acceptable. But since this is really HTML, those rules sometimes don't apply. Have you tried using application/xhtml+xml as your content type? If you do that, the browser might use an XML parsed instead of an HTML parser, *and* you are likely to get the benefit of using avoiding a quirks rendering more and instead use a standards-compliant parser *and* renderer. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #2 from jones...@oildex.com --- TAGX and JSPX only. Standard JSPs Tags don't seem to exhibit this. Interestingly, JSP *Documents* having an extension of just jsp (rather than jspx) don't seem to either. Generated JSP(X)/Tag(X) = the filename_jsp(x).java that Jasper creates. eg.) script type=text/javascript src=/docp/js/common/common.js/script Becomes: out.write(script src=\/docp/js/common/common.js\ type=\text/javascript\/); The testcase should be as simple as adding the sample snippet above to a JSP and compiling it using Jasper. We'll apply your recommendation to dodge this, thanks. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 58095] Empty script tag results in generated jsp having a self-closing script tag, which is invalid and results in rendering issues
https://bz.apache.org/bugzilla/show_bug.cgi?id=58095 --- Comment #1 from Christopher Schultz ch...@christopherschultz.net --- Do you have a test case? Is this .jspx or .jsp? What does generated jsp mean? Recommendation for suppressing the coalescing of the tags: script type=text/javascript src=/somepath/myfile.js!-- comment --/script -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org