summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2017-10-24 08:42:24 +0200
committerJan Lehnardt <jan@apache.org>2017-10-24 16:47:17 +0200
commit3ae2e5c94d8c275c50274809cb52eeffadb2b6b6 (patch)
tree08d1d2007a1849ffa04aaf4fbbf2d83ebbbf768b
parent2a9134c3c3a8f060e0d881dc1fb6e55c2644bf91 (diff)
downloadcouchdb-3ae2e5c94d8c275c50274809cb52eeffadb2b6b6.tar.gz
feat: add warning about redirects without a slash
-rw-r--r--src/couch/src/couch_httpd.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl
index b3bbd5baa..1694ac87f 100644
--- a/src/couch/src/couch_httpd.erl
+++ b/src/couch/src/couch_httpd.erl
@@ -536,7 +536,7 @@ host_for_request(#httpd{mochi_req=MochiReq}) ->
Value -> Value
end.
-absolute_uri(#httpd{mochi_req=MochiReq}=Req, Path) ->
+absolute_uri(#httpd{mochi_req=MochiReq}=Req, [$/ | _] = Path) ->
Host = host_for_request(Req),
XSsl = config:get("httpd", "x_forwarded_ssl", "X-Forwarded-Ssl"),
Scheme = case MochiReq:get_header_value(XSsl) of
@@ -552,7 +552,9 @@ absolute_uri(#httpd{mochi_req=MochiReq}=Req, Path) ->
end
end
end,
- Scheme ++ "://" ++ Host ++ Path.
+ Scheme ++ "://" ++ Host ++ Path;
+absolute_uri(_Req, _Path) ->
+ throw({bad_request, "path must begin with a /."}).
unquote(UrlEncodedString) ->
mochiweb_util:unquote(UrlEncodedString).