- bufaddenv(dst, "SCRIPT_NAME", "%.*s", (int)(strlen(url) - strlen(req->rest)), url);
- } else {
- bufaddenv(dst, "SCRIPT_NAME", "%s", url);
- }
+ url[strlen(url) - strlen(req->rest)] = 0;
+ }
+ if((pi = unquoteurl(req->rest)) == NULL)
+ pi = sstrdup(req->rest);
+ if(!strcmp(url, "/")) {
+ /* This seems to be normal CGI behavior, but see callcgi.c for
+ * details. */
+ url[0] = 0;
+ pi = sprintf2("/%s", tmp = pi);
+ free(tmp);
+ }
+ bufaddenv(dst, "PATH_INFO", "%s", pi);
+ bufaddenv(dst, "SCRIPT_NAME", "%s", url);