diff options
author | Jan Lehnardt <jan@apache.org> | 2017-10-24 08:42:24 +0200 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2017-10-24 16:47:17 +0200 |
commit | 3ae2e5c94d8c275c50274809cb52eeffadb2b6b6 (patch) | |
tree | 08d1d2007a1849ffa04aaf4fbbf2d83ebbbf768b | |
parent | 2a9134c3c3a8f060e0d881dc1fb6e55c2644bf91 (diff) | |
download | couchdb-3ae2e5c94d8c275c50274809cb52eeffadb2b6b6.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). |