You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Sutton <pa...@c2.net> on 1998/02/28 15:40:59 UTC

Win32 PATH_INFO wrong

PR#1786 notes that any trailing / on a path info component is lost.
So /cgi-bin/printenv/something/ reports that PATH_INFO is /something
rather than /something (and PATH_TRANSLATED is similarly wrong).

This is because Window's GetFullPathName() function silently
trashes any trailing \ component of the filename to be expanded to a full
path. The patch below hacks around this.

Paul
---

Index: util_win32.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/win32/util_win32.c,v
retrieving revision 1.8
diff -u -r1.8 util_win32.c
--- util_win32.c	1998/02/08 18:50:51	1.8
+++ util_win32.c	1998/02/28 14:37:10
@@ -12,11 +12,17 @@
     char *szFilePart;
     WIN32_FIND_DATA d;
     HANDLE h;
+    int add_trailing_slash = 0;
 
     n = GetFullPathName(szFile, sizeof buf, buf, &szFilePart);
     assert(n);
     assert(n < sizeof buf);
 
+    if (*szFile && szFile[strlen(szFile)-1] == '/') {
+        add_trailing_slash = 1;
+    }
+        
+
     if (!strchr(buf, '*') && !strchr(buf, '?')) {
         h = FindFirstFile(buf, &d);
         if(h != INVALID_HANDLE_VALUE)
@@ -51,6 +57,9 @@
     else {
         strlwr(d.cFileName);
         strcat(szCanon, d.cFileName);
+    }
+    if (add_trailing_slash) {
+        strcat(szCanon, "/");
     }
 }
 



Re: Win32 PATH_INFO wrong

Posted by Ben Laurie <be...@algroup.co.uk>.
Paul Sutton wrote:
> 
> PR#1786 notes that any trailing / on a path info component is lost.
> So /cgi-bin/printenv/something/ reports that PATH_INFO is /something
> rather than /something (and PATH_TRANSLATED is similarly wrong).
> 
> This is because Window's GetFullPathName() function silently
> trashes any trailing \ component of the filename to be expanded to a full
> path. The patch below hacks around this.

Surely this should be done in os_canonical_filename() not in
sub_canonical_filename()?

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache