diff options
author | ILYA Khlopotov <iilyak@apache.org> | 2018-11-22 13:12:48 +0000 |
---|---|---|
committer | ILYA Khlopotov <iilyak@apache.org> | 2018-11-22 21:00:28 +0000 |
commit | bae96cd40be5d952b2a35a39caa3f308bbe9d0b5 (patch) | |
tree | 12cd157ee2bb7f910d8227c0010b99901c1c27c7 | |
parent | 97dc9b05b2e75037739fef6834f0aefda04f8ac1 (diff) | |
download | couchdb-bae96cd40be5d952b2a35a39caa3f308bbe9d0b5.tar.gz |
Do not use [] in feature_flags configuration
[] characters are fobidden in configuration keys for security reason.
Use list without [] to configure flags. Example configuration:
[feature_flags]
foo,bar,baz||test* = true
-rw-r--r-- | src/couch/src/couch_flags_config.erl | 40 | ||||
-rw-r--r-- | src/couch/test/couch_flags_tests.erl | 14 |
2 files changed, 27 insertions, 27 deletions
diff --git a/src/couch/src/couch_flags_config.erl b/src/couch/src/couch_flags_config.erl index ad45add31..2d4532a88 100644 --- a/src/couch/src/couch_flags_config.erl +++ b/src/couch/src/couch_flags_config.erl @@ -120,8 +120,8 @@ parse_flags(_Tokens, _) -> [flag_id()] | {error, Reason :: term()}. parse_flags_term(FlagsBin) -> - case couch_util:parse_term(FlagsBin) of - {ok, Flags} when is_list(Flags) -> + case couch_util:parse_term(<<"[", FlagsBin/binary, "]">>) of + {ok, Flags} -> lists:usort(Flags); Term -> {error, { @@ -272,12 +272,12 @@ get_config_section(Section) -> all_combinations_return_same_result_test_() -> Config = [ - {"[foo, bar]||*", "true"}, - {"[baz, qux]||*", "false"}, - {"[baz]||shards/test*", "true"}, - {"[baz]||shards/blacklist*", "false"}, - {"[bar]||shards/test*", "false"}, - {"[bar]||shards/test/blacklist*", "true"} + {"foo, bar||*", "true"}, + {"baz, qux||*", "false"}, + {"baz||shards/test*", "true"}, + {"baz||shards/blacklist*", "false"}, + {"bar||shards/test*", "false"}, + {"bar||shards/test/blacklist*", "true"} ], Expected = [ {{<<"shards/test/blacklist*">>},{<<"shards/test/blacklist*">>,22,[bar, foo]}}, @@ -303,12 +303,12 @@ rules_are_sorted_test() -> latest_overide_wins_test_() -> Cases = [ {[ - {"[flag]||*", "false"}, {"[flag]||a*", "true"}, - {"[flag]||ab*", "true"}, {"[flag]||abc*", "true"} + {"flag||*", "false"}, {"flag||a*", "true"}, + {"flag||ab*", "true"}, {"flag||abc*", "true"} ], true}, {[ - {"[flag]||*", "true"}, {"[flag]||a*", "false"}, - {"[flag]||ab*", "true"}, {"[flag]||abc*", "false"} + {"flag||*", "true"}, {"flag||a*", "false"}, + {"flag||ab*", "true"}, {"flag||abc*", "false"} ], false} ], [{test_id(Rules, Expected), @@ -327,14 +327,14 @@ test_id(Items) -> test_config() -> [ - {"[flag_foo]||*", "true"}, - {"[flag_bar]||*", "false"}, - {"[flag_bar]||shards/test*", "true"}, - {"[flag_foo]||shards/blacklist*", "false"}, - {"[baz]||shards/test*", "true"}, - {"[baz]||shards/test/blacklist*", "false"}, - {"[flag_bar]||shards/exact", "true"}, - {"[flag_bar]||shards/test/exact", "true"} + {"flag_foo||*", "true"}, + {"flag_bar||*", "false"}, + {"flag_bar||shards/test*", "true"}, + {"flag_foo||shards/blacklist*", "false"}, + {"baz||shards/test*", "true"}, + {"baz||shards/test/blacklist*", "false"}, + {"flag_bar||shards/exact", "true"}, + {"flag_bar||shards/test/exact", "true"} ]. -endif. diff --git a/src/couch/test/couch_flags_tests.erl b/src/couch/test/couch_flags_tests.erl index f8f27c7c0..a467265cb 100644 --- a/src/couch/test/couch_flags_tests.erl +++ b/src/couch/test/couch_flags_tests.erl @@ -136,11 +136,11 @@ match_performance() -> test_config() -> [ - {"[foo]||/*", "true"}, - {"[bar]||/*", "false"}, - {"[bar]||/shards/test*", "true"}, - {"[foo]||/shards/blacklist*", "false"}, - {"[baz]||/shards/test*", "true"}, - {"[bar]||/shards/exact", "true"}, - {"[bar]||/shards/test/exact", "true"} + {"foo||/*", "true"}, + {"bar||/*", "false"}, + {"bar||/shards/test*", "true"}, + {"foo||/shards/blacklist*", "false"}, + {"baz||/shards/test*", "true"}, + {"bar||/shards/exact", "true"}, + {"bar||/shards/test/exact", "true"} ]. |