Created attachment 25441 [details] 2010-05-15_tc7_attribute_name_whitespace-test.patch The /test/webapp-3.0/bug45nnn/bug45015b.jsp page of trunk contains the following text: <tags:echo echo="hello "wo"rld" /> Running the test (testBug45015b of org.apache.jasper.compiler.TestGenerator) produces the following message: org.apache.jasper.JasperException: /bug45nnn/bug45015b.jsp(21,30) equal symbol expected It means, that the parser interprets "wo" as an attribute name, ignoring the fact that there is no whitespace before it. If I write <tags:echo echo="hello "wo="rld" /> the test complains that attribute "wo" is invalid for the tag, and finally if I write <tags:echo echo="hello "echo="rld" /> the test succeeds, while I would expect it to fail. I am attaching a patch that adds a testcase based on the last example, though a better testcase is needed that does not use the same attribute name twice. I think it is a minor issue, because this issue does not affect valid JSP pages, though allows to run some invalid ones. It is reproducible in the current 6.0 and 5.5 as well (thus 6.0.26, 5.5.29): if I add the following to /webapps/examples/jsp/simpletag/foo.jsp of TC6 (or the respective page in TC5.5): <ul> <eg:foo att1="1"att2="2"att3="3"> <li><%= member %></li> </eg:foo> </ul> and call http://localhost:8080/examples/jsp/simpletag/foo.jsp the page runs successfully and displays "1, 2, 3" list items among its output. Expected result: show some compilation error, e.g. ">, /> or whitespace was expected".
(In reply to comment #0) > It means, that the parser interprets "wo" as an attribute name, ignoring the > fact that there is no whitespace before it. Which spec requires there to be white-space before an attribute name? I can't see why it would be necessary. > If I write > <tags:echo echo="hello "wo="rld" /> > the test complains that attribute "wo" is invalid for the tag, I don't see this issue here. That is what I would expect to happen. > and finally if I write > <tags:echo echo="hello "echo="rld" /> > the test succeeds, while I would expect it to fail. That is a little more odd. I'm not sure what I would expect in that case. I'd need to do some spec research on that one.
(In reply to comment #1) > (In reply to comment #0) > > It means, that the parser interprets "wo" as an attribute name, ignoring the > > fact that there is no whitespace before it. > > Which spec requires there to be white-space before an attribute name? I can't > see why it would be necessary. > From jsp-2_1-fr-spec.pdf: JSP.1.3.2 Element Syntax "Action elements follow the syntax of an XML element." JSP.1.3.10.1 EBNF Grammar for JSP Syntax AllBody ::= ... ( ‘<‘ CustomAction CustomActionBody ) CustomAction ::= TagPrefix ’:’ CustomActionName CustomActionBody ::= ( Attributes CustomActionEnd ) Attributes ::= ( S Attribute )* S? [ vc: UniqueAttSpec ] The 'S' before Attribute means that a space is required, and UniqueAttSpec says that the same attribute name cannot appear more than once.
(In reply to comment #2) > The 'S' before Attribute means that a space is required Thanks for the reference. It still seems pointless, but we should fix it. Not something I think we need to worry about for 7.0.0. >UniqueAttSpec says that the same attribute name cannot appear more than once. Now that I can see the point of. More important, but still not a show stopper for 7.0.0 in my view.
Fixed in 7.0.x and will be included in 7.0.5 onwards.
Created attachment 26275 [details] Fix the spec broken code in related code of this bug. Hello, the fix of this bug recently result in some JSP TCK failures of geronimo. According to jsp spec : "A translation error will occur if the page directive defines duplicate attribute/values within a given translation unit, unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times." Adding a patch with testcases to fix this.
Reopen it because we have regressions here.
Created attachment 26276 [details] Fix the spec broken code in related code of this bug. ops, update the patch to include a missed block.
The quote above along with some comments in the patch suggests an ambiguity in the spec. The JSP 2.2 language is quite clear: <quote> There shall be only one occurrence of any attribute/value pair defined by this directive in a given translation unit, unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times. Multiple uses of the import attribute are cumulative (with ordered set union semantics). The pageEncoding attribute can occur at most once per file (or a translation error will result), and applies only to the file in which it appears. </quote>
Thanks for the patch. I didn't use it exactly but I did base the final fix on your patch. The fix is in 7.0.x and will be included in 7.0.5 onwards.
Thank Mark, The fix works like a charm with pageDirective, but we should include the same logic for tag Directive according to the spec. Per JSP.8.5.1 The tag Directive "The tag directive is similar to the page directive, but applies to tag files instead of JSPs. Like the page directive, a translation unit can contain more than one instance of the tag directive, all the attributes will apply to the complete translation unit (i.e. tag directives are position independent). There shall be only one occurrence of any attribute/value defined by this directive in a given translation unit,unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times. Multiple uses of the import attribute are cumulative (with ordered set union semantics). Other such multiple attribute/value (re)definitions result in a fatal translation error if the values do not match."
Tag directives fixed too
I have tried on apache-tomcat-7.0.11 problem is still there and not yet fixed. if fixed by this time. please guide us how to resolve.
This issue is fixed. Bugzilla is not a support forum. Please direct your enquiry to the Tomcat users mailing list.