From 04ad72ef44160e2d01795218711d64f415360ba4 Mon Sep 17 00:00:00 2001 From: Unbit Date: Sat, 18 Oct 2014 04:19:41 +0200 Subject: [PATCH] fixed php SCRIPT_NAME usage when --php-app is in place --- plugins/php/php_plugin.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/php/php_plugin.c b/plugins/php/php_plugin.c index 1dda41d4..c46c9301 100644 --- a/plugins/php/php_plugin.c +++ b/plugins/php/php_plugin.c @@ -674,6 +674,7 @@ int uwsgi_php_request(struct wsgi_request *wsgi_req) { size_t real_filename_len = 0; struct stat php_stat; char *filename = NULL; + int force_empty_script_name = 0; zend_file_handle file_handle; @@ -742,6 +743,7 @@ int uwsgi_php_request(struct wsgi_request *wsgi_req) { appready: wsgi_req->path_info = ""; wsgi_req->path_info_len = 0; + force_empty_script_name = 1; goto secure2; } @@ -871,13 +873,19 @@ secure2: } secure3: - wsgi_req->script_name = orig_path_info; - if (path_info) { - wsgi_req->script_name_len = path_info - orig_path_info; + if (force_empty_script_name) { + wsgi_req->script_name = ""; + wsgi_req->script_name_len = 0; } else { - wsgi_req->script_name_len = orig_path_info_len; - } + wsgi_req->script_name = orig_path_info; + if (path_info) { + wsgi_req->script_name_len = path_info - orig_path_info; + } + else { + wsgi_req->script_name_len = orig_path_info_len; + } + } #ifdef UWSGI_DEBUG uwsgi_log("php filename = %s script_name = %.*s (%d) document_root = %.*s (%d)\n", real_filename, wsgi_req->script_name_len, wsgi_req->script_name, wsgi_req->script_name_len,