diff --exclude='*~' --exclude='.*' -I '$Id:' -urN lighttpd-1.3.16.orig/src/mod_fastcgi.c lighttpd-1.3.16/src/mod_fastcgi.c --- lighttpd-1.3.16.orig/src/mod_fastcgi.c 2005-08-01 23:15:30.000000000 -0400 +++ lighttpd-1.3.16/src/mod_fastcgi.c 2005-08-01 23:30:01.000000000 -0400 @@ -331,6 +331,8 @@ pid_t pid; int got_proc; + + buffer *extension; /* used extension, used for SCRIPT_NAME/PATH_INFO of check-local=0 */ plugin_config conf; @@ -357,6 +359,7 @@ hctx->response = buffer_init(); hctx->response_header = buffer_init(); hctx->write_buffer = buffer_init(); + hctx->extension = buffer_init(); hctx->request_id = 0; hctx->state = FCGI_STATE_INIT; @@ -377,6 +380,7 @@ buffer_free(hctx->response); buffer_free(hctx->response_header); buffer_free(hctx->write_buffer); + buffer_free(hctx->extension); if (hctx->rb) { if (hctx->rb->ptr) free(hctx->rb->ptr); @@ -1654,22 +1658,74 @@ * For AUTHORIZER mode these headers should be omitted. */ - fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)); + if (host->check_local == 0 && + !buffer_is_empty(hctx->extension) && + hctx->extension->ptr[0] == '/') { + char *sl; + /* no local check and path-prefix /fcgi_pattern + * + * zope needs this + * + * SCRIPT_NAME => /fcgi_pattern + * PATH_INFO => uri.path - /fcgi_pattern + * + */ + + /* search for / in uri.path after /fcgi_pattern + * + * uri.path = /zope/abc + * + * pattern SCRIPT_NAME PATH_INFO + * /zop /zope /abc + * /zope/ /zope /abc + * /zope/abc /zope/abc (empty) + * / /zope/abc (empty) + * + */ + if (hctx->extension->used == 2) { + /* ext is / only */ + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), CONST_STR_LEN("")); + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->uri.path)); + + } else if (hctx->extension->ptr[hctx->extension->used - 2] == '/') { + /* last character is a / */ + + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), con->uri.path->ptr, hctx->extension->used - 2); + if (con->uri.path->used > hctx->extension->used) { + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), + con->uri.path->ptr + hctx->extension->used - 2, + con->uri.path->used - hctx->extension->used + 1); + } else { + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_STR_LEN("")); + } + + } else if (NULL != (sl = strchr(con->uri.path->ptr + hctx->extension->used - 1, '/'))) { + /* a trailing slash was found */ + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), con->uri.path->ptr, sl - con->uri.path->ptr - 1); + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), sl, strlen(sl)); + } else { + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)); + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_STR_LEN("")); + } + + } else { + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)); - if (!buffer_is_empty(con->request.pathinfo)) { - fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo)); - - /* PATH_TRANSLATED is only defined if PATH_INFO is set */ + if (!buffer_is_empty(con->request.pathinfo)) { + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo)); + + /* PATH_TRANSLATED is only defined if PATH_INFO is set */ - if (!buffer_is_empty(host->docroot)) { - buffer_copy_string_buffer(p->path, host->docroot); + if (!buffer_is_empty(host->docroot)) { + buffer_copy_string_buffer(p->path, host->docroot); + } else { + buffer_copy_string_buffer(p->path, con->physical.doc_root); + } + buffer_append_string_buffer(p->path, con->request.pathinfo); + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path)); } else { - buffer_copy_string_buffer(p->path, con->physical.doc_root); + fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_STR_LEN("")); } - buffer_append_string_buffer(p->path, con->request.pathinfo); - fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path)); - } else { - fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_INFO"), CONST_STR_LEN("")); } } @@ -3044,6 +3100,7 @@ hctx = handler_ctx_init(); + buffer_copy_string_buffer(hctx->extension, extension->key); hctx->remote_conn = con; hctx->plugin_data = p; hctx->host = host;