couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [couchdb] 01/01: feat: add warning about redirects without a slash
Date Tue, 24 Oct 2017 06:43:36 GMT
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch add-redirect-warning
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 16a159dfe81c1178fd4aee1eea5436ec4435931f
Author: Jan Lehnardt <jan@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" <commits@couchdb.apache.org>.

Mime
View raw message