[Zope] netscape fastrack server and zope..?

Matthew T. Kromer matt@bane.mi.org
Tue, 28 Sep 1999 08:22:58 -0400 (EDT)


Michel Pelletier wrote:
> Jens Vagelpohl wrote:
> > [Log snipped]
> > 10.1.1.1 - - [28/Sep/1999:01:57:43 +0000] "POST /Zope/. HTTP/1.0" 404 247
> > 0.550
> > </snippers>
> 
> This is because Netscape, incorrectly, prevents a request from acessing
> the '.' "document" in a folder (which should be the folder itself).
> 
> Using '.' is not a violation of the HTTP spec, and every other web
> server i've used handles it properly.
> 
> You can fix this by changing all ocurances of '.' in Zope's DTML source
> with URL1

Since that sounds so extreme, here's a patch to nscgi-auth.c instead which
strips /. from the end of URLs.  Add the parameter stripdot=1 to the
NameTrans fn="cgiauth-nametrans" function, e.g.

	NameTrans fn="cgiauth-nametrans" stripdot=1

I hereby assign all rights to this patch to Digitial Creations provided I
am waived of all warranty requirements, requirements of fitness for a particular
purpose, etc.  (For what it's worth...)


--- /home/matt/ftp/nscgi/nscgi-auth.c	Mon Aug 11 17:37:58 1997
+++ nscgi-auth.c	Tue Sep 28 08:17:07 1999
@@ -187,6 +187,32 @@
 NSAPI_PUBLIC int cgiauth_nametrans(pblock *pb, Session *sn, Request *rq)
 {
    char *aheader = pblock_findval("authorization", rq->headers);
+   char *stripdot = pblock_findval("stripdot", pb);
+
+   if (stripdot)
+   { /* Lets clean up the reference to /. (not Malda!) */
+	char *ppath = pblock_findval("ppath", rq->vars);
+	if (ppath)
+	{  /* Zip to the end of the string and look for . */
+	   char *c = ppath;
+
+	   while (*c) c++; c--;
+	   if (*c == '.' && ((*(c - 1) == '/') || *(c - 1) == '\\')) 
+	   {	/* I don't know if pblock_findval returns a copy or the
+		** original pointer, but let's be safe
+		*/
+		pb_param *pp = pblock_find("ppath", rq->vars);
+		char *oldp;
+
+		c--;	/* Strip off the /., not just the . */
+		*c = '\0';
+
+		oldp = pp->value;
+		pp->value = STRDUP(ppath);
+		FREE(oldp);
+	   }
+	}
+   }
 
    if (aheader)
    { /* There was a header, so see if it matches any of our allow entries.*/

-- 
Matt Kromer			"Where are we going?"		"Planet 10!"
matt@bane.mi.org		"When?"				"Real soon!"
http://bane.mi.org/~matt