You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/06/22 20:14:20 UTC
[couchdb] branch fix-comment-parsing-in-config updated (0e174623a -> 21c421d2f)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch fix-comment-parsing-in-config
in repository https://gitbox.apache.org/repos/asf/couchdb.git
discard 0e174623a Fix the ability to use ; in config values
new 21c421d2f Fix the ability to use ; in config values
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (0e174623a)
\
N -- N -- N refs/heads/fix-comment-parsing-in-config (21c421d2f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
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.
Summary of changes:
[couchdb] 01/01: Fix the ability to use ; in config values
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch fix-comment-parsing-in-config
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 21c421d2f118d2ab84a130d87543b5f82a8dacf0
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Thu Jun 22 16:08:36 2023 -0400
Fix the ability to use ; in config values
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.
Fixes: https://github.com/apache/couchdb/issues/4651
---
src/config/src/config.erl | 42 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/src/config/src/config.erl b/src/config/src/config.erl
index 72dff72d8..1f8ee2cab 100644
--- a/src/config/src/config.erl
+++ b/src/config/src/config.erl
@@ -480,8 +480,18 @@ read_ini_file(IniFile) ->
end.
remove_comments(Line) ->
- {NoComments, _Comments} = string:take(Line, [$;], true),
- NoComments.
+ case trim(Line) of
+ [$; | _] ->
+ % Comment is at the start of line after it's trimmed
+
+ % empty line will be removed in a filter function later
+ "";
+ NoLeadingComment when is_list(NoLeadingComment) ->
+ % Comment may be in-line. However, only consider it a comment if preceeded
+ % by a space or a tab as some values may have ; separated parts
+ [NoComments | _] = re:split(NoLeadingComment, " ;|\t;", [{return, list}]),
+ NoComments
+ end.
% Specially handle the ?DELETE marker
%
@@ -650,6 +660,10 @@ parse_skip_test() ->
?assertEqual([], ini("s]\nk=v")),
?assertEqual([], ini(";[s]\nk = v")),
?assertEqual([], ini(" ; [s]\nk = v")),
+ ?assertEqual([], ini("[s]\n ;k = v")),
+ ?assertEqual([], ini("[s]\n;;k = v")),
+ ?assertEqual([], ini("[s]\n\t;k = v")),
+ ?assertEqual([], ini("[s]\nk ;=v")),
?assertEqual([], ini("[s]\n ; k = v")),
?assertEqual([], ini("[]\nk = v")),
?assertEqual([], ini(";[s]\n ")).
@@ -681,14 +695,32 @@ parse_extra_equal_sign_test() ->
parse_delete_test() ->
?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk=")),
- ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk=;")),
?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk =")),
?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk = ")),
?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk= ")),
?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk = ")),
?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk = ;")),
- ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk =;")),
- ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk=\n")).
+ ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk =\t;")),
+ ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk=\n")),
+ ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk = ; ;")),
+ ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk = ;v")),
+ ?assertEqual([{{"s", "k"}, ?DELETE}], ini("[s]\nk = ;")).
+
+parse_comments_test() ->
+ ?assertEqual([], ini("[s]\n;k=v")),
+ ?assertEqual([{{"s", "k"}, ";"}], ini("[s]\nk=;")),
+ ?assertEqual([{{"s", "k"}, ";"}], ini("[s]\nk =;")),
+ ?assertEqual([{{"s", "k"}, "v;"}], ini("[s]\nk = v;")),
+ ?assertEqual([{{"s", "k"}, ";v;"}], ini("[s]\nk =;v;")),
+ ?assertEqual([{{"s", "k"}, ";v"}], ini("[s]\nk =;v")),
+ ?assertEqual([{{"s", "k"}, "v;"}], ini("[s]\nk =v;")),
+ ?assertEqual([{{"s", "k"}, "v;;"}], ini("[s]\nk =v;;")),
+ ?assertEqual([{{"s", "k"}, "v1;v2"}], ini("[s]\nk = v1;v2")),
+ ?assertEqual([{{"s", "k"}, "v1;v2;v3"}], ini("[s]\nk = v1;v2;v3")),
+ ?assertEqual([{{"s", "k"}, "v1;v2"}], ini("[s]\nk = v1;v2 ;")),
+ ?assertEqual([{{"s", "k"}, "v1;v2"}], ini("[s]\nk = v1;v2\t;")),
+ ?assertEqual([{{"s", "k"}, "v1;v2"}], ini("[s]\nk = v1;v2 ;;")),
+ ?assertEqual([{{"s", "k"}, "v1;v2"}], ini("[s]\nk = v1;v2 ;c1; c2")).
parse_multiple_kvs_test() ->
?assertEqual(