Bug 62808 - "function-signature" text containing line breaks causes JasperException
Summary: "function-signature" text containing line breaks causes JasperException
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 7.0.91
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-09 02:59 UTC by katsuta_k
Modified: 2018-10-15 11:50 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description katsuta_k 2018-10-09 02:59:55 UTC
When a function was defined in tld file with function-signature containing line breaks causes JasperException in Tomcat v7.0.91.

For example
```
  <function>
    <name>getSomething</name>
    <function-class>com.example.Functions</function-class>
    <function-signature>
      com.example getSomething(com.example.longpackagename.Foo,
            com.example.longpackagename.Bar,
            com.example.longpackagename.Baz)
    </function-signature>
  </function>
```

This function definition works well in Tomcat v7.0.85 But not work in Tomcat v7.0.91.
In Tomcat v7.0.91, this definition causes JasperException like bellow.

```
Oct 09, 2018 11:22:04 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Invalid syntax for function signature in TLD.  Tag Library: xxx, Function: getSomething
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:56)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:445)
	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:165)
	at org.apache.jasper.compiler.Validator$ValidateVisitor.getMethod(Validator.java:1648)
	at org.apache.jasper.compiler.Validator$ValidateVisitor.processSignature(Validator.java:1635)
	at org.apache.jasper.compiler.Validator$ValidateVisitor.access$400(Validator.java:420)
	at org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1611)
	at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:139)
...

```

However, according to the specification of JSR 245, "function-signature" can contain line breaks (LF or CRLF).
So I think that this behavior violates the specification.
http://download.oracle.com/otn-pub/jcp/jsp-2.1-fr-spec-oth-JSpec/jsp-2_1-fr-spec.pdf


The detail of definition is below.
The spec of "function-signature" element was defined in p. 3-32 as follows.
```
            function-signature element is as follows: 
                FunctionSignature ::= ReturnType S MethodName S? 
                                      ’(’ S? Parameters? S? ’)’ 
                ReturnType        ::= Type 
                MethodName        ::= Identifier 
                Parameters        ::=   Parameter 
                                      | ( Parameter S? ’,’ S? Parameters ) 
                Parameter         ::= Type 
```

The "S" was defined as follows.
p. 1-27
```
S::= XML::
```

p. 1-16
```
The prefix XML:: is used to refer to an EBNF definition in the XML 1.0 speci-
fication. Refer to http://www.w3.org/TR/REC-xml
```

https://www.w3.org/TR/REC-xml/#NT-S
```
S (white space) consists of one or more space (#x20) characters, carriage returns, line feeds, or tabs.
```



We think that this change is ​​the cause of this problem and I'm afraid that the same change was ​​also done in Tomcat v8.0.x and v9.0.x
ref. http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Validator.java?r1=1840104&r2=1840103&pathrev=1840104
Comment 1 Mark Thomas 2018-10-09 09:32:59 UTC
There was a regression in 7.0.91 that is fixed for 7.0.92 in this area. I suspect this is the same issue but need to test it to be sure.
Comment 2 Mark Thomas 2018-10-15 11:20:30 UTC
It is a related issue but not the same. Investigating...
Comment 3 Mark Thomas 2018-10-15 11:50:42 UTC
Fixed in:
- trunk for 9.0.13 onwards
- 8.5.x for 8.5.35 onwards
- 7.0.x for 7.0.92 onwards

Note: This regression only made it into a 7.0.x release.