mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
SCRIPT_FILENAME should be relative to document root, and begin with slash.
This commit is contained in:
1 parent
fb87fd5343
commit
7865ed7bad
1 file changed
+8
-10
+8
-10
@@ -1528,7 +1528,7 @@ static void convert_uri_to_file_name(struct mg_connection *conn,
|
|||||||
change_slashes_to_backslashes(buf);
|
change_slashes_to_backslashes(buf);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
DEBUG_TRACE(("[%s] -> [%s]", uri, buf));
|
DEBUG_TRACE(("[%s] -> [%s], [%.*s]", uri, buf, (int) vec.len, vec.ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sslize(struct mg_connection *conn, int (*func)(SSL *)) {
|
static int sslize(struct mg_connection *conn, int (*func)(SSL *)) {
|
||||||
@@ -2743,7 +2743,7 @@ static char *addenv(struct cgi_env_block *block, const char *fmt, ...) {
|
|||||||
static void prepare_cgi_environment(struct mg_connection *conn,
|
static void prepare_cgi_environment(struct mg_connection *conn,
|
||||||
const char *prog,
|
const char *prog,
|
||||||
struct cgi_env_block *blk) {
|
struct cgi_env_block *blk) {
|
||||||
const char *s, *script_filename, *slash;
|
const char *s, *slash;
|
||||||
struct vec var_vec, root;
|
struct vec var_vec, root;
|
||||||
char *p;
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
@@ -2751,11 +2751,6 @@ static void prepare_cgi_environment(struct mg_connection *conn,
|
|||||||
blk->len = blk->nvars = 0;
|
blk->len = blk->nvars = 0;
|
||||||
blk->conn = conn;
|
blk->conn = conn;
|
||||||
|
|
||||||
// SCRIPT_FILENAME
|
|
||||||
script_filename = prog;
|
|
||||||
if ((s = strrchr(prog, '/')) != NULL)
|
|
||||||
script_filename = s + 1;
|
|
||||||
|
|
||||||
get_document_root(conn, &root);
|
get_document_root(conn, &root);
|
||||||
|
|
||||||
addenv(blk, "SERVER_NAME=%s", conn->ctx->config[AUTHENTICATION_DOMAIN]);
|
addenv(blk, "SERVER_NAME=%s", conn->ctx->config[AUTHENTICATION_DOMAIN]);
|
||||||
@@ -2773,10 +2768,13 @@ static void prepare_cgi_environment(struct mg_connection *conn,
|
|||||||
addenv(blk, "REMOTE_PORT=%d", conn->request_info.remote_port);
|
addenv(blk, "REMOTE_PORT=%d", conn->request_info.remote_port);
|
||||||
addenv(blk, "REQUEST_URI=%s", conn->request_info.uri);
|
addenv(blk, "REQUEST_URI=%s", conn->request_info.uri);
|
||||||
|
|
||||||
|
// SCRIPT_NAME
|
||||||
|
assert(conn->request_info.uri[0] == '/');
|
||||||
slash = strrchr(conn->request_info.uri, '/');
|
slash = strrchr(conn->request_info.uri, '/');
|
||||||
addenv(blk, "SCRIPT_NAME=%.*s%s",
|
if ((s = strrchr(prog, '/')) == NULL)
|
||||||
(slash - conn->request_info.uri) + 1, conn->request_info.uri,
|
s = prog;
|
||||||
script_filename);
|
addenv(blk, "SCRIPT_NAME=%.*s%s", slash - conn->request_info.uri,
|
||||||
|
conn->request_info.uri, s);
|
||||||
|
|
||||||
addenv(blk, "SCRIPT_FILENAME=%s", prog);
|
addenv(blk, "SCRIPT_FILENAME=%s", prog);
|
||||||
addenv(blk, "PATH_TRANSLATED=%s", prog);
|
addenv(blk, "PATH_TRANSLATED=%s", prog);
|
||||||
|
|||||||
Reference in new issue
Block a user