couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject chttpd commit: updated refs/heads/master to f9cad9d
Date Wed, 29 Jul 2015 17:33:47 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 07493ef4c -> f9cad9dd1


Port max_rewrites to chttpd

This commit incorporates the original work by Ronny Pfannschmidt
<Ronny.Pfannschmidt@gmx.de> and myself for COUCHDB-1441 and COUCHDB-1651.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/f9cad9dd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/f9cad9dd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/f9cad9dd

Branch: refs/heads/master
Commit: f9cad9dd19fd175d8b26da3d5af10ba70e3513d1
Parents: 07493ef
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Jul 29 18:17:27 2015 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 29 18:23:10 2015 +0100

----------------------------------------------------------------------
 src/chttpd.erl         | 1 +
 src/chttpd_rewrite.erl | 9 +++++++++
 2 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/f9cad9dd/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 1e80a53..31c16d3 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -130,6 +130,7 @@ stop() ->
 
 handle_request(MochiReq0) ->
     Begin = os:timestamp(),
+    erlang:put(?REWRITE_COUNT, 0),
     MochiReq = couch_httpd_vhost:dispatch_host(MochiReq0),
 
     case config:get("chttpd", "socket_options") of

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/f9cad9dd/src/chttpd_rewrite.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_rewrite.erl b/src/chttpd_rewrite.erl
index 902f6e9..87198d4 100644
--- a/src/chttpd_rewrite.erl
+++ b/src/chttpd_rewrite.erl
@@ -119,6 +119,15 @@ handle_rewrite_req(#httpd{
     Prefix = <<"/", DbName/binary, "/", DesignId/binary>>,
     QueryList = lists:map(fun decode_query_value/1, chttpd:qs(Req)),
 
+    RewritesSoFar = erlang:get(?REWRITE_COUNT),
+    MaxRewrites = config:get_integer("httpd", "rewrite_limit", 100),
+    case RewritesSoFar >= MaxRewrites of
+        true ->
+            throw({bad_request, <<"Exceeded rewrite recursion limit">>});
+        false ->
+            erlang:put(?REWRITE_COUNT, RewritesSoFar + 1)
+    end,
+
     #doc{body={Props}} = DDoc,
 
     % get rules from ddoc


Mime
View raw message