You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Larry Isaacs <La...@sas.com> on 2000/11/15 13:33:24 UTC

[PROPOSED 3.2B7 PATCH] error displayed for case mismatch in JSP U RL

In Tomcat 3.2b7 (and earlier), invoking
http://localhost:8080/test/jsp/Helloworld.jsp results in an NPE in
JspCompiler.isOutDated().  This occurs because getRealPath() returns
null since the 'w' should be uppercase, hence it is considered an
"unsafe" path.  To make this error return "file not found", I propose
the following patches for 3.2b7.

===== JspCompiler.java Patch =====
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java,v
retrieving revision 1.14.2.1
diff -u -r1.14.2.1 JspCompiler.java
--- JspCompiler.java	2000/07/25 20:45:09	1.14.2.1
+++ JspCompiler.java	2000/11/15 12:13:12
@@ -304,7 +304,11 @@
     public boolean isOutDated() {
         File jspReal = null;
 
-        jspReal = new File(ctxt.getRealPath(jsp.getPath()));
+        String realPath = ctxt.getRealPath(jsp.getPath());
+        if (realPath == null)
+            return true;
+
+        jspReal = new File(realPath);
 
         File classFile = new File(getClassFileName());
         if (classFile.exists()) {
==================================

===== JspReader.java patch =====
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
retrieving revision 1.16.2.4
diff -u -r1.16.2.4 JspReader.java
--- JspReader.java	2000/11/06 04:08:14	1.16.2.4
+++ JspReader.java	2000/11/15 12:12:29
@@ -171,6 +171,9 @@
 	    ? file.getAbsolutePath()
 	    : context.getRealPath(file.toString());
 
+	if (longName == null)
+	    throw new FileNotFoundException(file.toString());
+
 	int fileid = registerSourceFile(longName);
 	
         if (fileid == -1)
================================

This probably won't eliminate the head scratching, but at least they will
be scratching their heads for the right reason. :-)  Also, this will make
section 6.7 in the Readme correct about the error seen due to a case mismatch.

If no one objects, I'll commit these changes this afternoon.

Cheers,
Larry

Re: [PROPOSED 3.2B7 PATCH] error displayed for case mismatch in JSP URL

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
+1

Craig


Larry Isaacs wrote:

> In Tomcat 3.2b7 (and earlier), invoking
> http://localhost:8080/test/jsp/Helloworld.jsp results in an NPE in
> JspCompiler.isOutDated().  This occurs because getRealPath() returns
> null since the 'w' should be uppercase, hence it is considered an
> "unsafe" path.  To make this error return "file not found", I propose
> the following patches for 3.2b7.
>
> ===== JspCompiler.java Patch =====
> RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java,v
> retrieving revision 1.14.2.1
> diff -u -r1.14.2.1 JspCompiler.java
> --- JspCompiler.java    2000/07/25 20:45:09     1.14.2.1
> +++ JspCompiler.java    2000/11/15 12:13:12
> @@ -304,7 +304,11 @@
>      public boolean isOutDated() {
>          File jspReal = null;
>
> -        jspReal = new File(ctxt.getRealPath(jsp.getPath()));
> +        String realPath = ctxt.getRealPath(jsp.getPath());
> +        if (realPath == null)
> +            return true;
> +
> +        jspReal = new File(realPath);
>
>          File classFile = new File(getClassFileName());
>          if (classFile.exists()) {
> ==================================
>
> ===== JspReader.java patch =====
> RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
> retrieving revision 1.16.2.4
> diff -u -r1.16.2.4 JspReader.java
> --- JspReader.java      2000/11/06 04:08:14     1.16.2.4
> +++ JspReader.java      2000/11/15 12:12:29
> @@ -171,6 +171,9 @@
>             ? file.getAbsolutePath()
>             : context.getRealPath(file.toString());
>
> +       if (longName == null)
> +           throw new FileNotFoundException(file.toString());
> +
>         int fileid = registerSourceFile(longName);
>
>          if (fileid == -1)
> ================================
>
> This probably won't eliminate the head scratching, but at least they will
> be scratching their heads for the right reason. :-)  Also, this will make
> section 6.7 in the Readme correct about the error seen due to a case mismatch.
>
> If no one objects, I'll commit these changes this afternoon.
>
> Cheers,
> Larry
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

Re: [PROPOSED 3.2B7 PATCH] error displayed for case mismatch in JSP U RL

Posted by cm...@yahoo.com.
+1

Costin

> ===== JspCompiler.java Patch =====
> RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java,v
> retrieving revision 1.14.2.1
> diff -u -r1.14.2.1 JspCompiler.java
> --- JspCompiler.java	2000/07/25 20:45:09	1.14.2.1
> +++ JspCompiler.java	2000/11/15 12:13:12
> @@ -304,7 +304,11 @@
>      public boolean isOutDated() {
>          File jspReal = null;
>  
> -        jspReal = new File(ctxt.getRealPath(jsp.getPath()));
> +        String realPath = ctxt.getRealPath(jsp.getPath());
> +        if (realPath == null)
> +            return true;
> +
> +        jspReal = new File(realPath);
>  
>          File classFile = new File(getClassFileName());
>          if (classFile.exists()) {
> ==================================
> 
> ===== JspReader.java patch =====
> RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
> retrieving revision 1.16.2.4
> diff -u -r1.16.2.4 JspReader.java
> --- JspReader.java	2000/11/06 04:08:14	1.16.2.4
> +++ JspReader.java	2000/11/15 12:12:29
> @@ -171,6 +171,9 @@
>  	    ? file.getAbsolutePath()
>  	    : context.getRealPath(file.toString());
>  
> +	if (longName == null)
> +	    throw new FileNotFoundException(file.toString());
> +
>  	int fileid = registerSourceFile(longName);
>  	
>          if (fileid == -1)
> ================================
> 
> This probably won't eliminate the head scratching, but at least they will
> be scratching their heads for the right reason. :-)  Also, this will make
> section 6.7 in the Readme correct about the error seen due to a case mismatch.
> 
> If no one objects, I'll commit these changes this afternoon.
> 
> Cheers,
> Larry
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>