diff options
author | Taylor Yu <catalyst@torproject.org> | 2019-07-03 15:13:51 -0500 |
---|---|---|
committer | Taylor Yu <catalyst@torproject.org> | 2019-12-08 17:09:42 -0600 |
commit | 4b22c739fe8b04b05e7bdfdf18ec42ec4bf1c436 (patch) | |
tree | 7580363b1638c03d6c84f3e84c197cf71d5331b7 /src/test/test_config.c | |
parent | 089466eff356454b0e0eb4e1d432057504a9a4d6 (diff) | |
download | tor-4b22c739fe8b04b05e7bdfdf18ec42ec4bf1c436.tar.gz tor-4b22c739fe8b04b05e7bdfdf18ec42ec4bf1c436.zip |
clean up kvline_can_encode_lines()
Add a check for '=' characters in needs_escape(). This simplifies the
logic in kvline_can_encode_lines().
Part of #30984.
Diffstat (limited to 'src/test/test_config.c')
-rw-r--r-- | src/test/test_config.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c index a75a862739..6294e21f04 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -6050,6 +6050,28 @@ test_config_kvline_parse(void *arg) tt_str_op(lines->next->next->value, OP_EQ, "I"); enc = kvline_encode(lines, KV_OMIT_VALS|KV_QUOTED); tt_str_op(enc, OP_EQ, "AB=\"CD E\" DE FGH=I"); + tor_free(enc); + config_free_lines(lines); + + lines = kvline_parse("AB=CD \"EF=GH\"", KV_OMIT_KEYS|KV_QUOTED); + tt_assert(lines); + tt_str_op(lines->key, OP_EQ, "AB"); + tt_str_op(lines->value, OP_EQ, "CD"); + tt_str_op(lines->next->key, OP_EQ, ""); + tt_str_op(lines->next->value, OP_EQ, "EF=GH"); + enc = kvline_encode(lines, KV_OMIT_KEYS); + tt_assert(!enc); + enc = kvline_encode(lines, KV_OMIT_KEYS|KV_QUOTED); + tt_assert(enc); + tt_str_op(enc, OP_EQ, "AB=CD \"EF=GH\""); + tor_free(enc); + config_free_lines(lines); + + lines = tor_malloc_zero(sizeof(*lines)); + lines->key = tor_strdup("A=B"); + lines->value = tor_strdup("CD"); + enc = kvline_encode(lines, 0); + tt_assert(!enc); done: config_free_lines(lines); |