Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 41001 invoked from network); 16 Mar 2010 00:52:50 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Mar 2010 00:52:50 -0000 Received: (qmail 80250 invoked by uid 500); 16 Mar 2010 00:52:50 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 80217 invoked by uid 500); 16 Mar 2010 00:52:50 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 80210 invoked by uid 99); 16 Mar 2010 00:52:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Mar 2010 00:52:50 +0000 X-ASF-Spam-Status: No, hits=-1001.2 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Mar 2010 00:52:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9B22B23889B8; Tue, 16 Mar 2010 00:52:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r923530 - in /couchdb/branches/0.11.x: ./ etc/default/couchdb src/couchdb/couch_server.erl src/couchdb/couch_util.erl Date: Tue, 16 Mar 2010 00:52:28 -0000 To: commits@couchdb.apache.org From: davisp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100316005228.9B22B23889B8@eris.apache.org> Author: davisp Date: Tue Mar 16 00:52:28 2010 New Revision: 923530 URL: http://svn.apache.org/viewvc?rev=923530&view=rev Log: Backporting 923526 - fix couch_server:all_databases/0 Modified: couchdb/branches/0.11.x/ (props changed) couchdb/branches/0.11.x/etc/default/couchdb (props changed) couchdb/branches/0.11.x/src/couchdb/couch_server.erl couchdb/branches/0.11.x/src/couchdb/couch_util.erl Propchange: couchdb/branches/0.11.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Mar 16 00:52:28 2010 @@ -6,4 +6,4 @@ /couchdb/branches/list-iterator:782292-784593 /couchdb/branches/tail_header:775760-778477 /couchdb/tags/0.10.0:825400 -/couchdb/trunk:909247,910054,910696,910910-910911,911544,911559,911578,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707 +/couchdb/trunk:909247,910054,910696,910910-910911,911544,911559,911578,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707,923526 Propchange: couchdb/branches/0.11.x/etc/default/couchdb ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Mar 16 00:52:28 2010 @@ -6,5 +6,5 @@ /couchdb/branches/list-iterator/etc/default/couchdb:782292-784593 /couchdb/branches/tail_header/etc/default/couchdb:775760-778477 /couchdb/tags/0.10.0/etc/default/couchdb:825400 -/couchdb/trunk/etc/default/couchdb:909247,910054,910696,911544,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707 +/couchdb/trunk/etc/default/couchdb:909247,910054,910696,911544,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707,923526 /incubator/couchdb/trunk/etc/default/couchdb:642419-694440 Modified: couchdb/branches/0.11.x/src/couchdb/couch_server.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_server.erl?rev=923530&r1=923529&r2=923530&view=diff ============================================================================== --- couchdb/branches/0.11.x/src/couchdb/couch_server.erl (original) +++ couchdb/branches/0.11.x/src/couchdb/couch_server.erl Tue Mar 16 00:52:28 2010 @@ -153,10 +153,12 @@ terminate(Reason, _Srv) -> all_databases() -> {ok, #server{root_dir=Root}} = gen_server:call(couch_server, get_server), + NormRoot = couch_util:normpath(Root), Filenames = filelib:fold_files(Root, "^[a-z0-9\\_\\$()\\+\\-]*[\\.]couch$", true, fun(Filename, AccIn) -> - case Filename -- Root of + NormFilename = couch_util:normpath(Filename), + case NormFilename -- NormRoot of [$/ | RelativeFilename] -> ok; RelativeFilename -> ok end, Modified: couchdb/branches/0.11.x/src/couchdb/couch_util.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_util.erl?rev=923530&r1=923529&r2=923530&view=diff ============================================================================== --- couchdb/branches/0.11.x/src/couchdb/couch_util.erl (original) +++ couchdb/branches/0.11.x/src/couchdb/couch_util.erl Tue Mar 16 00:52:28 2010 @@ -12,7 +12,7 @@ -module(couch_util). --export([priv_dir/0, start_driver/1,terminate_linked/1]). +-export([priv_dir/0, start_driver/1, normpath/1, terminate_linked/1]). -export([should_flush/0, should_flush/1, to_existing_atom/1]). -export([rand32/0, implode/2, collate/2, collate/3]). -export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]). @@ -50,6 +50,19 @@ start_driver(LibDir) -> exit(erl_ddll:format_error(Error)) end. +% Normalize a pathname by removing .. and . components. +normpath(Path) -> + normparts(filename:split(Path), []). + +normparts([], Acc) -> + filename:join(lists:reverse(Acc)); +normparts([".." | RestParts], [_Drop | RestAcc]) -> + normparts(RestParts, RestAcc); +normparts(["." | RestParts], Acc) -> + normparts(RestParts, Acc); +normparts([Part | RestParts], Acc) -> + normparts(RestParts, [Part | Acc]). + % works like list_to_existing_atom, except can be list or binary and it % gives you the original value instead of an error if no existing atom. to_existing_atom(V) when is_list(V) ->