- if(*req->rest && (strlen(url) > strlen(req->rest)) &&
- !strcmp(req->rest, url + strlen(url) - strlen(req->rest)) &&
- (url[strlen(url) - strlen(req->rest) - 1] == '/')) {
- bufaddenv(dst, "SCRIPT_NAME", "%.*s", (int)(strlen(url) - strlen(req->rest) - 1), url);
- } else {
- bufaddenv(dst, "SCRIPT_NAME", "%s", url);
+ if(*req->rest && (strlen(url) >= strlen(req->rest)) &&
+ !strcmp(req->rest, url + strlen(url) - strlen(req->rest))) {
+ 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);