commit - 3c19febb014ddc7d9afa1b517c108da4b3fda5dc
commit + aa0fe0cf240e0add51d5b60a83dd554fd0575b28
blob - c8348a0fa50bb6a6a3c9f05881989b5b30c17cf5
blob + a057e17c4114ec7ef7f6088adf27405a4273d1ea
--- gmid.c
+++ gmid.c
char *url_after_proto(char*);
char *url_start_of_request(char*);
int url_trim(struct client*, char*);
-void adjust_path(char*);
+char *adjust_path(char*);
int path_isdir(char*);
ssize_t filesize(int);
return 1;
}
-void
+char *
adjust_path(char *path)
{
- char *s;
+ char *s, *query;
size_t len;
+
+ if ((query = strchr(path, '?')) != NULL) {
+ *query = '\0';
+ query++;
+ }
/* /.. -> / */
len = strlen(path);
/* if the path is only `..` trim out and exit */
if (!strcmp(path, "..")) {
path[0] = '\0';
- return;
+ return query;
}
/* remove every ../ in the path */
while (1) {
if ((s = strstr(path, "../")) == NULL)
- return;
+ return query;
memmove(s, s+3, strlen(s)+1); /* copy also the \0 */
}
}
{
char buf[GEMINI_URL_LEN];
char *path;
+ char *query;
switch (client->state) {
case S_OPEN:
return;
}
- adjust_path(path);
- LOG(client, "get %s", path);
+ query = adjust_path(path);
+ LOG(client, "get %s%s%s", path,
+ query ? "?" : "",
+ query ? query : "");
if (path_isdir(path))
send_dir(path, fds, client);