Bug 57099 - loose parsing of import attribute in page directive screws up SMAP output
loose parsing of import attribute in page directive screws up SMAP output
Product: Tomcat 7
Classification: Unclassified
Component: Jasper
PC Mac OS X 10.1
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2014-10-15 20:14 UTC by Daniel Garcia
Modified: 2014-10-16 13:48 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Garcia 2014-10-15 20:14:01 UTC
Came across some customer code that had the following in their jsp files:

 page session="false"
         import java.util.*;
         import java.text.*;
         import java.util.Date.*;
         import java.text.DecimalFormat;
         import com.xyz.debug.Debug;
         import com.xyz.failure.*;
         import com.xyz.messaging.*;
         import com.xyz.utils.*;
         import com.xyz.xml_messaging.*;
         import com.xyz.environment.*;
         import generated.screening_engine.*;
         import generated.xml_utils.*;"

Even though the JSP spec says that the import statement should be "The value is as in an import declaration in the Java programming language, a (comma separated) list of either a fully qualified Java programming language type name denoting that type, or of a package name followed by the .* string, denoting all the public types declared in that package." this is parsed/compiled by the JSP parser." these folks seem to have stumbled on to a, well, different way of specifying a list of imports.

Since the JSP parser only sees a "single" import and believes it has merely written a single import line, the SMAP numbering ends up being off by, in this case, 12, causing all sorts of fun down the line when trying to map back to original jsp code by way of the SMAP file.

In short, it appears that one could, in an import statement, append a semicolon and then put whatever java code they want, and it would go in and get compiled in as long as there weren't any commas in it.
Comment 1 Mark Thomas 2014-10-16 13:44:46 UTC
Thanks for the report. This is fixed in 8.0.x for 8.0.15 onwards.
Comment 2 Mark Thomas 2014-10-16 13:48:36 UTC
And also fixed in 7.0.x for 7.0.57 onwards.