You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2017/10/26 00:26:17 UTC
[couchdb] branch 2.1.x updated: feat: add warning about redirects
without a slash
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/2.1.x by this push:
new 68d0090 feat: add warning about redirects without a slash
68d0090 is described below
commit 68d009081c0686486ea3d939947c82944c6a46a5
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Oct 24 08:42:24 2017 +0200
feat: add warning about redirects without a slash
---
src/couch/src/couch_httpd.erl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl
index b3bbd5b..1694ac8 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).
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].