diff options
author | Jan Lehnardt <jan@apache.org> | 2017-10-24 08:42:24 +0200 |
---|---|---|
committer | Joan Touzet <wohali@users.noreply.github.com> | 2017-10-25 20:26:15 -0400 |
commit | 68d009081c0686486ea3d939947c82944c6a46a5 (patch) | |
tree | 90bdd049fc8c5d5786a8eefd77b3aa0f9bf12377 | |
parent | b6da4d948ee239b9fa83868f060344cbb09c1efd (diff) | |
download | couchdb-68d009081c0686486ea3d939947c82944c6a46a5.tar.gz |
feat: add warning about redirects without a slash
-rw-r--r-- | src/couch/src/couch_httpd.erl | 6 |
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). |