You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2017/10/24 06:43:35 UTC

[couchdb] branch add-redirect-warning created (now 16a159d)

This is an automated email from the ASF dual-hosted git repository.

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


      at 16a159d  feat: add warning about redirects without a slash

This branch includes the following new commits:

     new 16a159d  feat: add warning about redirects without a slash

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 01/01: feat: add warning about redirects without a slash

Posted by ja...@apache.org.
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 <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>.