From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v1 1/1] third_party: fix strings "true"/"false" in yaml Date: Thu, 12 Jul 2018 15:58:58 +0300 [thread overview] Message-ID: <0ed926e6936c70a9c7ac7c917f278505c243fe07.1531400260.git.kshcherbatov@tarantool.org> (raw) Strings containing "true" and "false" were converted to a boolean type when serializing. Fixed. Example: type(yaml.decode(yaml.encode('false'))) == string type(yaml.decode(yaml.encode('true'))) == string Closes #3476. --- https://github.com/tarantool/tarantool/compare/kshch/gh-3476-yaml-strings-with-true-and-false https://github.com/tarantool/tarantool/issues/3476 test/app-tap/console.test.lua | 10 +++++++++- third_party/lua-yaml/lyaml.cc | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua index f055958..1c76072 100755 --- a/test/app-tap/console.test.lua +++ b/test/app-tap/console.test.lua @@ -21,7 +21,7 @@ local EOL = "\n...\n" test = tap.test("console") -test:plan(53) +test:plan(57) -- Start console and connect to it local server = console.listen(CONSOLE_SOCKET) @@ -67,6 +67,14 @@ test:is(yaml.decode(client:read(EOL))[1], ';', "get delimiter is ';'") client:write("require('console').delimiter('');\n") test:is(yaml.decode(client:read(EOL)), '', "clear delimiter") +-- +-- gh-3476: yaml.encode encodes 'false' and 'true' incorrectly. +-- +test:is(type(yaml.decode(yaml.encode('false'))), 'string') +test:is(type(yaml.decode(yaml.encode('true'))), 'string') +test:is(type(yaml.decode(yaml.encode({a = 'false'})).a), 'string') +test:is(type(yaml.decode(yaml.encode({a = 'false'})).a), 'string') + box.cfg{ listen=IPROTO_SOCKET; memtx_memory = 107374182, diff --git a/third_party/lua-yaml/lyaml.cc b/third_party/lua-yaml/lyaml.cc index 14eabca..c6d118a 100644 --- a/third_party/lua-yaml/lyaml.cc +++ b/third_party/lua-yaml/lyaml.cc @@ -605,9 +605,12 @@ static int dump_node(struct lua_yaml_dumper *dumper) if (utf8_check_printable(str, len)) { if (yaml_is_flow_mode(dumper)) { style = YAML_SINGLE_QUOTED_SCALAR_STYLE; - } else if (strstr(str, "\n\n") != NULL) { + } else if (strstr(str, "\n\n") != NULL || strcmp(str, "true") == 0 || + strcmp(str, "false") == 0) { /* - * Tarantool-specific: use literal style for string with empty lines. + * Tarantool-specific: use literal style for string + * with empty lines and strings representing boolean + * types. * Useful for tutorial(). */ style = YAML_LITERAL_SCALAR_STYLE; -- 2.7.4
next reply other threads:[~2018-07-12 12:59 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-12 12:58 Kirill Shcherbatov [this message] 2018-07-13 6:48 ` [tarantool-patches] " Kirill Yukhin 2018-07-19 10:54 ` Kirill Yukhin 2018-07-19 12:11 ` Alexander Turenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=0ed926e6936c70a9c7ac7c917f278505c243fe07.1531400260.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] third_party: fix strings "true"/"false" in yaml' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox