Skip to content
Snippets Groups Projects
Commit a2d7643c authored by Kirill Shcherbatov's avatar Kirill Shcherbatov Committed by Kirill Yukhin
Browse files

third_party: fix strings "true"/"false" in yaml

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.
parent 455e8898
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment