You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stefano Mazzocchi <st...@apache.org> on 2000/01/23 14:06:43 UTC

Re: [PATCH] Fix for ServletExec 2.2 getRealPath problem + Fix for VisualCafe 4.0 bug

"Timm, Sean" wrote:
> 
> The following diff provides the fixes to handle the problem with ServletExec
> 2.2 returning various kinds of slashes for getRealPath depending on the type
> of URI request.  You'll also notice that I pulled the creation of the
> StringTokenizer object out of each for loop.  VisualCafe 4.0 has some sort
> of problem parsing the file when that line is located within the for which
> made it very difficult to do any sort of debugging (even though it would
> still compile...)
> 
> - Sean T.
> 
> Index: Utils.java
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Utils.java,v
> retrieving revision 1.4
> diff -u -r1.4 Utils.java
> --- Utils.java  2000/01/15 11:19:17     1.4
> +++ Utils.java  2000/01/23 07:57:41
> @@ -138,7 +138,9 @@
> 
>          while (nodes.hasMoreElements()) {
>              String data = ((ProcessingInstruction)
> nodes.nextElement()).getData();
> -            for (StringTokenizer st = new StringTokenizer(data, " \t=");
> st.hasMoreTokens();) {
> +
> +            StringTokenizer st = new StringTokenizer(data, " \t=");
> +            for (; st.hasMoreTokens(); ) {
>                  String key = st.nextToken();
>                  String token = st.nextToken();
>                  token = token.substring(1, token.length() - 1);
> @@ -158,7 +160,8 @@
>          Hashtable attributes = new Hashtable();
> 
>          String data = pi.getData();
> -        for (StringTokenizer st = new StringTokenizer(data, " \t=");
> st.hasMoreTokens();) {
> +        StringTokenizer st = new StringTokenizer(data, " \t=");
> +        for (; st.hasMoreTokens();) {
>              String key = st.nextToken();
>              String token = st.nextToken();
>              token = token.substring(1, token.length() - 1);
> @@ -237,7 +240,7 @@
>                  return request.getPathTranslated().replace('\\','/');
>              } else {
>                  // otherwise use the deprecated method on all other servlet
> engines.
> -                return request.getRealPath(request.getRequestURI());
> +                return
> request.getRealPath(request.getRequestURI()).replace('\\', '/');
>              }
>          } catch (MalformedURLException e) {
>              throw new RuntimeException("Malformed request URL.");

the replace() patch was already applied in latest CVS, but in the wrong
place (Ricardo moved the code around and I missed it).

I'll apply the other two as a bug workaround.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------