added php-app-qs

This commit is contained in:
Giovanni Scala
2012-11-22 06:26:36 +01:00
parent 7fcc8ba6ac
commit d719ed6a3b
+17 -1
View File
@@ -24,6 +24,7 @@ struct uwsgi_php {
struct uwsgi_string_list *append_config;
char *docroot;
char *app;
char *app_qs;
size_t ini_size;
int dump_config;
char *server_software;
@@ -49,6 +50,7 @@ struct uwsgi_option uwsgi_php_options[] = {
{"php-allowed-script", required_argument, 0, "list the allowed php scripts (require absolute path)", uwsgi_opt_add_string_list, &uphp.allowed_scripts, 0},
{"php-server-software", required_argument, 0, "force php SERVER_SOFTWARE", uwsgi_opt_set_str, &uphp.server_software, 0},
{"php-app", required_argument, 0, "force the php file to run at each request", uwsgi_opt_set_str, &uphp.app, 0},
{"php-app-qs", required_argument, 0, "when in app mode force QUERY_STRING to the specified value + REQUEST_URI", uwsgi_opt_set_str, &uphp.app_qs, 0},
{"php-dump-config", no_argument, 0, "dump php config (if modified via --php-set or append options)", uwsgi_opt_true, &uphp.dump_config, 0},
{0, 0, 0, 0, 0, 0, 0},
@@ -285,6 +287,9 @@ static void sapi_uwsgi_register_variables(zval *track_vars_array TSRMLS_DC)
}
php_register_variable_safe("PATH_INFO", wsgi_req->path_info, wsgi_req->path_info_len, track_vars_array TSRMLS_CC);
if (wsgi_req->query_string_len > 0) {
php_register_variable_safe("QUERY_STRING", wsgi_req->query_string, wsgi_req->query_string_len, track_vars_array TSRMLS_CC);
}
php_register_variable_safe("SCRIPT_NAME", wsgi_req->script_name, wsgi_req->script_name_len, track_vars_array TSRMLS_CC);
php_register_variable_safe("SCRIPT_FILENAME", wsgi_req->file, wsgi_req->file_len, track_vars_array TSRMLS_CC);
@@ -768,7 +773,18 @@ int uwsgi_php_request(struct wsgi_request *wsgi_req) {
strcpy(real_filename, uphp.app);
wsgi_req->path_info = "";
wsgi_req->path_info_len = 0;
goto secure2;
if (wsgi_req->uri_len == 1 && wsgi_req->uri[0] == '/') {
goto secure2;
}
if (uphp.app_qs) {
size_t app_qs_len = strlen(uphp.app_qs);
char *qs = ecalloc(1, wsgi_req->uri_len + 1 + app_qs_len);
memcpy(qs, uphp.app_qs, app_qs_len);
memcpy(qs+app_qs_len, wsgi_req->uri, wsgi_req->uri_len);
wsgi_req->query_string = qs;
wsgi_req->query_string_len = wsgi_req->uri_len + app_qs_len;
goto secure2;
}
}
char *filename = uwsgi_concat4n(wsgi_req->document_root, wsgi_req->document_root_len, "/", 1, wsgi_req->path_info, wsgi_req->path_info_len, "", 0);