From f599b16ec561ce29ad009d70c3e205cacf633be4 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 11 Jul 2017 22:00:45 -1000 Subject: url-decode search query --- gopher.filter.dpi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'gopher.filter.dpi.c') diff --git a/gopher.filter.dpi.c b/gopher.filter.dpi.c index 27eb489..faef30b 100644 --- a/gopher.filter.dpi.c +++ b/gopher.filter.dpi.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -422,11 +423,22 @@ static void render_image(int s, const char *url) { static void fix_path(char *path) { char *query, *start, *end; + char buf[3]; /* change form input name to query */ start = query = strstr(path, "__gopher__query__="); if (!start) return; end = start + 18; - while ((*start++ = *end++)); + while (*end) { + if (*end == '%') { + strncpy(buf, end + 1, 2); + *start++ = strtoul(buf, NULL, 16); + end += 2; + } + else if (*end == '+') *start++ = ' '; + else *start++ = *end; + end++; + } + *start = '\0'; query[-1] = '\t'; } -- cgit v1.2.3