[htdig3-dev] Re: What's left for 3.1.0


Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Tue, 26 Jan 1999 14:17:02 -0600 (CST)


According to Geoff Hutchison:
> OTHER BUGS:
..
> * Double slashes are eliminated even if they're part of a CGI query string.

How's this?

--- ./htlib/URL.cc.slashbug Tue Jan 26 13:22:29 1999
+++ ./htlib/URL.cc Tue Jan 26 14:05:05 1999
@@ -384,7 +384,10 @@
     // We will rewrite the path to be the minimal.
     //
     int i, limit;
- while ((i = _path.indexOf("/../")) >= 0)
+ int pathend = _path.indexOf('?'); // Don't mess up query strings.
+ if (pathend < 0)
+ pathend = _path.length();
+ while ((i = _path.indexOf("/../")) >= 0 && i < pathend)
     {
         if ((limit = _path.lastIndexOf('/', i - 1)) >= 0)
         {
@@ -397,39 +400,51 @@
         {
             _path = _path.sub(i + 3).get();
         }
+ pathend = _path.indexOf('?');
+ if (pathend < 0)
+ pathend = _path.length();
     }
 
     //
     // Also get rid of redundent "/./". This could cause infinite
     // loops.
     //
- while ((i = _path.indexOf("/./")) >= 0)
+ while ((i = _path.indexOf("/./")) >= 0 && i < pathend)
     {
         String newPath;
         newPath << _path.sub(0, i).get();
         newPath << _path.sub(i + 2).get();
         _path = newPath;
+ pathend = _path.indexOf('?');
+ if (pathend < 0)
+ pathend = _path.length();
     }
 
     //
     // Furthermore, get rid of "//". This could also cause loops
     //
- while ((i = _path.indexOf("//")) >= 0)
+ while ((i = _path.indexOf("//")) >= 0 && i < pathend)
     {
         String newPath;
         newPath << _path.sub(0, i).get();
         newPath << _path.sub(i + 1).get();
         _path = newPath;
+ pathend = _path.indexOf('?');
+ if (pathend < 0)
+ pathend = _path.length();
     }
 
     // Finally change all "%7E" to "~" for sanity
- while ((i = _path.indexOf("%7E")) >= 0)
+ while ((i = _path.indexOf("%7E")) >= 0 && i < pathend)
       {
         String newPath;
         newPath << _path.sub(0, i).get();
         newPath << "~";
         newPath << _path.sub(i + 3).get();
         _path = newPath;
+ pathend = _path.indexOf('?');
+ if (pathend < 0)
+ pathend = _path.length();
       }
 }
 

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930
------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
htdig3-dev@htdig.org containing the single word "unsubscribe" in
the SUBJECT of the message.



This archive was generated by hypermail 2.0b3 on Thu Feb 04 1999 - 22:24:20 PST