Author: fhanik Date: Mon Aug 6 16:49:46 2007 New Revision: 563344 URL: http://svn.apache.org/viewvc?view=rev&rev=563344 Log: forward port from markt bug fixes in 6.0.x branch
Modified: tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Modified: tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java?view=diff&rev=563344&r1=563343&r2=563344 ============================================================================== --- tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java (original) +++ tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java Mon Aug 6 16:49:46 2007 @@ -187,7 +187,7 @@ * Decode and return the specified URL-encoded String. * When the byte array is converted to a string, the system default * character encoding is used... This may be different than some other - * servers. + * servers. It is assumed the string is not a query string. * * @param str The url-encoded string * @@ -195,14 +195,13 @@ * by a valid 2-digit hexadecimal number */ public static String URLDecode(String str) { - return URLDecode(str, null); - } - - + + /** - * Decode and return the specified URL-encoded String. + * Decode and return the specified URL-encoded String. It is assumed the + * string is not a query string. * * @param str The url-encoded string * @param enc The encoding to use; if null, the default encoding is used @@ -210,7 +209,19 @@ * by a valid 2-digit hexadecimal number */ public static String URLDecode(String str, String enc) { - + return URLDecode(str, enc, false); + } + + /** + * Decode and return the specified URL-encoded String. + * + * @param str The url-encoded string + * @param enc The encoding to use; if null, the default encoding is used + * @param isQuery Is this a query string being processed + * @exception IllegalArgumentException if a '%' character is not followed + * by a valid 2-digit hexadecimal number + */ + public static String URLDecode(String str, String enc, boolean isQuery) { if (str == null) return (null); @@ -226,13 +237,14 @@ } } catch (UnsupportedEncodingException uee) {} - return URLDecode(bytes, enc); + return URLDecode(bytes, enc, isQuery); } /** - * Decode and return the specified URL-encoded byte array. + * Decode and return the specified URL-encoded byte array. It is assumed + * the string is not a query string. * * @param bytes The url-encoded byte array * @exception IllegalArgumentException if a '%' character is not followed @@ -244,7 +256,8 @@ /** - * Decode and return the specified URL-encoded byte array. + * Decode and return the specified URL-encoded byte array. It is assumed + * the string is not a query string. * * @param bytes The url-encoded byte array * @param enc The encoding to use; if null, the default encoding is used @@ -252,7 +265,20 @@ * by a valid 2-digit hexadecimal number */ public static String URLDecode(byte[] bytes, String enc) { + return URLDecode(bytes, null, false); + } + /** + * Decode and return the specified URL-encoded byte array. + * + * @param bytes The url-encoded byte array + * @param enc The encoding to use; if null, the default encoding is used + * @param isQuery Is this a query string being processed + * @exception IllegalArgumentException if a '%' character is not followed + * by a valid 2-digit hexadecimal number + */ + public static String URLDecode(byte[] bytes, String enc, boolean isQuery) { + if (bytes == null) return (null); @@ -261,7 +287,7 @@ int ox = 0; while (ix < len) { byte b = bytes[ix++]; // Get byte to test - if (b == '+') { + if (b == '+' && isQuery) { b = (byte)' '; } else if (b == '%') { b = (byte) ((convertHexDigit(bytes[ix++]) << 4) Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java?view=diff&rev=563344&r1=563343&r2=563344 ============================================================================== --- tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java (original) +++ tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java Mon Aug 6 16:49:46 2007 @@ -305,8 +305,25 @@ // Check if the requested JSP page exists, to avoid // creating unnecessary directories and files. if (null == context.getResource(jspUri)) { - response.sendError(HttpServletResponse.SC_NOT_FOUND, - request.getRequestURI()); + String includeRequestUri = (String) + request.getAttribute( + "javax.servlet.include.request_uri"); + if (includeRequestUri != null) { + // This file was included. Throw an exception as + // a response.sendError() will be ignored + throw new ServletException(Localizer.getMessage( + "jsp.error.file.not.found",jspUri)); + } else { + try { + response.sendError( + HttpServletResponse.SC_NOT_FOUND, + request.getRequestURI()); + } catch (IllegalStateException ise) { + log.error(Localizer.getMessage( + "jsp.error.file.not.found", + jspUri)); + } + } return; } boolean isErrorPage = exception != null; Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java?view=diff&rev=563344&r1=563343&r2=563344 ============================================================================== --- tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java (original) +++ tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Mon Aug 6 16:49:46 2007 @@ -328,25 +328,6 @@ return; } - } catch (FileNotFoundException ex) { - ctxt.incrementRemoved(); - String includeRequestUri = (String) - request.getAttribute("javax.servlet.include.request_uri"); - if (includeRequestUri != null) { - // This file was included. Throw an exception as - // a response.sendError() will be ignored by the - // servlet engine. - throw new ServletException(ex); - } else { - try { - response.sendError(HttpServletResponse.SC_NOT_FOUND, - ex.getMessage()); - } catch (IllegalStateException ise) { - log.error(Localizer.getMessage("jsp.error.file.not.found", - ex.getMessage()), - ex); - } - } } catch (ServletException ex) { if (options.getDevelopment()) { throw handleJspException(ex); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]