2017-05-29 11:43 GMT+03:00 Mark Thomas <ma...@apache.org>:
> On 26/05/17 21:33, Christopher Schultz wrote:
>> Mark,
>>
>> On 5/26/17 6:59 AM, Mark Thomas wrote:
>>> On 26/05/17 10:15, David Kavanagh wrote:
>>>> Hey guys,
>>>>
>>>> Thanks for getting back to me. I didn't realise that the
>>>> attachments would be stripped.> Here are the two files in full.
>>
>>> That isn't enough for us to reproduce it. Those files refer to a
>>> handful of other tag files and classes we don't have.
>>
>>> However, I have been able to derive a simple test case from it:
>>
>>> =====start====== <p class="${'foo'} ${'bar'}">This is a test</p>
>>> ======end=======
>>
>>> The output with trimSpaces enabled is:
>>
>>> =====start====== <p class="foobar">This is a test</p>
>>> ======end=======
>>
>>> trimSpaces is behaving exactly as designed. It removes any blocks
>>> of template text that consist solely of white space.
>>
>>> What you have is: TemplateText [<p class="] Expression
>>> [${'foo'}] TemplateText [ ] Expression   [${'bar'}] TemplateText
>>> [">This is a test</p>]
>>
>>> Because the second template text is empty, it gets removed.
>>
>>> The fix is:
>>
>>> =====start====== <p class="${'foo'}${' '}${'bar'}">This is a
>>> test</p> ======end=======
>>
>>> This is a potential use case for a recently closed (as WONTFIX)
>>> enhancement request:
>>
>>> https://bz.apache.org/bugzilla/show_bug.cgi?id=45931
>>
>>> Whether this use case is sufficient to justify re-opening that
>>> enhancement request, reviewing the patch and updating it for 9.0.x
>>> is TBD. How realistic is it for you to apply the fix (using ${'
>>> '}) described above?
>>
>> Would it be reasonable to change trimSpaces so that spaces within
>> element attributes would be normalized to a single space, and others
>> would be removed? I'm not sure how aware the parser is of the
>> surrounding document structure.
>
> The parser is completely unaware. As far as it is concerned, it is just
> template text. Parsing the template text it is likely impossible since
> correct parsing depends on evaluating the entire page.

Aren't EL expressions a part of that template text?

=

Reading JSP 2.3 spec, there is

ch. JSP.1.9 Template Text Semantics
says that template text is uninterpreted

but
ch. JSP.2.2 Expressions and Template Text
says that EL can be used in template text.

ch. JSP.10.1.12 Template Text and XML Elements
talks about EL expressions that a part of template text

>From JSP.10.1.12 when mapping JSP pages into XML view,
the template text is mapped into <jsp:text> elements,
preserving EL expressions within the text.

=

The option that controls removal of whitespaces is called
"trimDirectiveWhitespaces".

Option of %@page directive is defined as

<quote, page "1-54" (90/594)>
Indicates how whitespaces in template text should be
handled. If true, template text that contains only whitespaces
is removed from the output. The default is not to trim
whitespaces. This attribute is useful to remove the
extraneous whitespaces from the end of a directive that is not
followed by template text. The corresponding JSP
configuration element is trim-directive-whitespaces (see
Section JSP.3.3.8, “Removing whitespaces from template
text”). The attribute is ignored by JSP documents (XML
syntax).
</quote>

Configuration option is defined in
JSP.3.3.8 Removing whitespaces from template text

The example in JSP.3.3.8 shows how whitespace is removed between
directives (<%..., JSP.1.10 Directives),
but there is no example of removing whitespace between EL.

There is also no example whether this option applies to custom tags
(aka JSP.1.13 Actions).

Jasper option "trimSpaces" is documented as
"Should white spaces in template text between actions or directives be
trimmed ?, default false."
http://tomcat.apache.org/tomcat-8.5-doc/jasper-howto.html

=

JSP.8.5.1 The tag Directive

<quote>
trimDirective-
Whitespaces
(optional) Carries the same syntax and semantics of the trim-
DirectiveWhitespaces attribute of the page directive.
However, there is no corresponding global configuration
element in web.xml.
</quote>

Thus the global configuration should not apply to tag files at all?

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to