Bug 57316 - JspC fails if directory name contains URL encoded characters
Summary: JspC fails if directory name contains URL encoded characters
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 7.0.55
Hardware: Macintosh All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-12-05 18:56 UTC by Alex Varju
Modified: 2014-12-15 10:52 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Alex Varju 2014-12-05 18:56:36 UTC
I ran into an issue today where my Jenkins build failed because the working directory contained '%2F' in the name.  When the build got as far as attempting to precompile the JSPs, an exception was thrown complaining that the directory didn't exist.

Gradle error output:

Internal Error: File /WEB-INF/web.xml not found
[ant:jasper] java.lang.NullPointerException
[ant:jasper]  at java.io.File.<init>(File.java:277)
[ant:jasper]  at org.apache.jasper.JspC.initClassLoader(JspC.java:1555)
[ant:jasper]  at org.apache.jasper.JspC.processFile(JspC.java:1196)
[ant:jasper]  at org.apache.jasper.JspC.execute(JspC.java:1362)
[ant:jasper]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[ant:jasper]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ant:jasper]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[ant:jasper]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ant:jasper]  at java.lang.reflect.Method.invoke(Method.java:606)
[ant:jasper]  at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[ant:jasper]  at groovy.util.AntBuilder.performTask(AntBuilder.java:260)

I believe the problem is caused by JspC.initClassLoader's call to JspCompilationContext.getRealPath.  This calls JspCServletContext.getRealPath, which in turn uses the value from URL.getFile to build the path.  This returns a URL encoded variant of the path, which in my case means a double-encoded path.  I believe JspCompilationContext.getRealPath should be URL decoding the return value.
Comment 1 Mark Thomas 2014-12-15 10:52:32 UTC
This did not affect trunk or 8.0.x as the code that caused the issue had already been removed.

This has been fixed in 7.0.x for 7.0.58 onwards.