aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@esdenera.com>2015-06-21 15:11:00 +0200
committerReyk Floeter <reyk@esdenera.com>2015-06-21 15:11:00 +0200
commit3e7417278dfa7c202b1325e78413714a76f0d3c5 (patch)
tree036b90bc331d10a4fd6c36fc979a9eedfc047f8c
parent120d520b19891000b704cf8fbd666c6a14e6b2ef (diff)
parent744267eb1f34a8852973f441256744ad535d2241 (diff)
downloadhttpd-3e7417278dfa7c202b1325e78413714a76f0d3c5.tar.gz
httpd-3e7417278dfa7c202b1325e78413714a76f0d3c5.zip
Merge branch 'master' into patterns
-rw-r--r--httpd/server_http.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/httpd/server_http.c b/httpd/server_http.c
index 26d5392..a63e2ab 100644
--- a/httpd/server_http.c
+++ b/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.80 2015/05/20 09:28:47 kettenis Exp $ */
+/* $OpenBSD: server_http.c,v 1.81 2015/06/21 13:08:36 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -886,7 +886,7 @@ server_expand_http(struct client *clt, const char *val, char *buf,
{
struct http_descriptor *desc = clt->clt_descreq;
struct server_config *srv_conf = clt->clt_srv_conf;
- char ibuf[128], *str, *path;
+ char ibuf[128], *str, *path, *query;
const char *errstr = NULL, *p;
size_t size;
int n, ret;
@@ -924,9 +924,15 @@ server_expand_http(struct client *clt, const char *val, char *buf,
return (NULL);
}
if (strstr(val, "$QUERY_STRING") != NULL) {
- if (expand_string(buf, len, "$QUERY_STRING",
- desc->http_query == NULL ? "" :
- desc->http_query) != 0)
+ if (desc->http_query == NULL) {
+ ret = expand_string(buf, len, "$QUERY_STRING", "");
+ } else {
+ if ((query = url_encode(desc->http_query)) == NULL)
+ return (NULL);
+ ret = expand_string(buf, len, "$QUERY_STRING", query);
+ free(query);
+ }
+ if (ret != 0)
return (NULL);
}
if (strstr(val, "$REMOTE_") != NULL) {
@@ -962,9 +968,13 @@ server_expand_http(struct client *clt, const char *val, char *buf,
if (desc->http_query == NULL) {
str = path;
} else {
- ret = asprintf(&str, "%s?%s",
- path, desc->http_query);
+ if ((query = url_encode(desc->http_query)) == NULL) {
+ free(path);
+ return (NULL);
+ }
+ ret = asprintf(&str, "%s?%s", path, query);
free(path);
+ free(query);
if (ret == -1)
return (NULL);
}