mirror of
https://github.com/gophernicus/gophernicus.git
synced 2024-11-03 04:27:17 -05:00
Rewrote parsing of ;vhost?query<tab>search from selector
This commit is contained in:
parent
d816ae110f
commit
cbfb8fb2eb
2
file.c
2
file.c
@ -355,7 +355,7 @@ void setenv_cgi(state *st, char *script)
|
||||
|
||||
setenv("SERVER_HOST", st->server_host, 1);
|
||||
setenv("REQUEST", st->req_selector, 1);
|
||||
setenv("SEARCHREQUEST", st->req_query_string, 1);
|
||||
setenv("SEARCHREQUEST", st->req_search, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -392,6 +392,7 @@ void init_state(state *st)
|
||||
strclear(st->req_selector);
|
||||
strclear(st->req_realpath);
|
||||
strclear(st->req_query_string);
|
||||
strclear(st->req_search);
|
||||
strclear(st->req_referrer);
|
||||
sstrlcpy(st->req_local_addr, get_local_address());
|
||||
sstrlcpy(st->req_remote_addr, get_peer_address());
|
||||
@ -628,6 +629,25 @@ get_selector:
|
||||
if (shm) get_shm_session(&st, shm);
|
||||
#endif
|
||||
|
||||
|
||||
/* Parse <tab>search from selector */
|
||||
if ((c = strchr(selector, '\t'))) {
|
||||
sstrlcpy(st.req_search, c + 1);
|
||||
*c = '\0';
|
||||
}
|
||||
|
||||
/* Parse ?query from selector */
|
||||
if (st.opt_query && (c = strchr(selector, '?'))) {
|
||||
sstrlcpy(st.req_query_string, c + 1);
|
||||
*c = '\0';
|
||||
}
|
||||
|
||||
/* Parse ;vhost from selector */
|
||||
if (st.opt_vhost && (c = strchr(selector, ';'))) {
|
||||
sstrlcpy(st.server_host, c + 1);
|
||||
*c = '\0';
|
||||
}
|
||||
|
||||
/* Loop through the selector, fix it & separate query_string */
|
||||
dest = st.req_selector;
|
||||
if (selector[0] != '/') *dest++ = '/';
|
||||
@ -638,27 +658,15 @@ get_selector:
|
||||
while (*c == '/' && *(c + 1) == '/') c++;
|
||||
if (*c == '/' && *(c + 1) == '.' && *(c + 2) == '/') c += 2;
|
||||
|
||||
/* Start of a query string (either type 7 or HTTP-style)? */
|
||||
if (*c == '\t' || (st.opt_query && *c == '?')) {
|
||||
sstrlcpy(st.req_query_string, c + 1);
|
||||
if ((c = strchr(st.req_query_string, '\t'))) *c = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
/* Start of virtual host hint? */
|
||||
if (*c == ';') {
|
||||
if (st.opt_vhost) sstrlcpy(st.server_host, c + 1);
|
||||
|
||||
/* Skip vhost on selector */
|
||||
while (*c && *c != '\t') c++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Copy valid char */
|
||||
*dest++ = *c++;
|
||||
}
|
||||
*dest = '\0';
|
||||
|
||||
/* Main query parameters compatibility with older versions of Gophernicus */
|
||||
if (*st.req_query_string && !*st.req_search) sstrlcpy(st.req_search, st.req_query_string);
|
||||
if (!*st.req_query_string && *st.req_search) sstrlcpy(st.req_query_string, st.req_search);
|
||||
|
||||
/* Remove encodings from selector */
|
||||
strndecode(st.req_selector, st.req_selector, sizeof(st.req_selector));
|
||||
|
||||
|
@ -291,6 +291,7 @@ typedef struct {
|
||||
char req_selector[BUFSIZE];
|
||||
char req_realpath[BUFSIZE];
|
||||
char req_query_string[BUFSIZE];
|
||||
char req_search[BUFSIZE];
|
||||
char req_referrer[BUFSIZE];
|
||||
char req_local_addr[64];
|
||||
char req_remote_addr[64];
|
||||
@ -356,7 +357,7 @@ typedef struct {
|
||||
/* Shared memory for session & accounting data */
|
||||
#ifdef HAVE_SHMEM
|
||||
|
||||
#define SHM_KEY 0xbeeb0007 /* Unique identifier + struct version */
|
||||
#define SHM_KEY 0xbeeb0008 /* Unique identifier + struct version */
|
||||
#define SHM_MODE 0600 /* Access mode for the shared memory */
|
||||
#define SHM_SESSIONS 256 /* Max amount of user sessions to track */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user