Skip to content

Commit

Permalink
Fix #354: yaml incorrectly escapces special characters in a string
Browse files Browse the repository at this point in the history
  • Loading branch information
rtsisyk committed May 29, 2015
1 parent 721b99c commit e0d3f3f
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 137 deletions.
6 changes: 5 additions & 1 deletion test/app/json.result
Expand Up @@ -203,11 +203,15 @@ ok - double
# boolean: end
ok - boolean
# string
1..4
1..8
ok - encode/decode for
ok - encode/decode for abcde
ok - encode/decode for Кудыкины горы
ok - encode/decode for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ok - encode/decode for $a $
ok - encode/decode for $a $
ok - encode/decode for $a\t $
ok - encode/decode for $a\\t $
# string: end
ok - string
# nil
Expand Down
6 changes: 5 additions & 1 deletion test/app/lua/serializer_test.lua
Expand Up @@ -202,11 +202,15 @@ local function test_boolean(test, s)
end

local function test_string(test, s)
test:plan(4)
test:plan(8)
rt(test, s, "")
rt(test, s, "abcde")
rt(test, s, "Кудыкины горы") -- utf-8
rt(test, s, string.rep("x", 33))
rt(test, s, '$a\t $')
rt(test, s, '$a\t $')
rt(test, s, [[$a\t $]])
rt(test, s, [[$a\\t $]])
end

local function test_nil(test, s)
Expand Down
6 changes: 5 additions & 1 deletion test/app/msgpack.result
Expand Up @@ -203,11 +203,15 @@ ok - double
# boolean: end
ok - boolean
# string
1..4
1..8
ok - encode/decode for
ok - encode/decode for abcde
ok - encode/decode for Кудыкины горы
ok - encode/decode for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ok - encode/decode for $a $
ok - encode/decode for $a $
ok - encode/decode for $a\t $
ok - encode/decode for $a\\t $
# string: end
ok - string
# nil
Expand Down
6 changes: 5 additions & 1 deletion test/app/msgpackffi.result
Expand Up @@ -197,11 +197,15 @@ ok - double
# boolean: end
ok - boolean
# string
1..4
1..8
ok - encode/decode for
ok - encode/decode for abcde
ok - encode/decode for Кудыкины горы
ok - encode/decode for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ok - encode/decode for $a $
ok - encode/decode for $a $
ok - encode/decode for $a\t $
ok - encode/decode for $a\\t $
# string: end
ok - string
# nil
Expand Down
10 changes: 8 additions & 2 deletions test/app/yaml.result
Expand Up @@ -203,11 +203,15 @@ ok - double
# boolean: end
ok - boolean
# string
1..4
1..8
ok - encode/decode for
ok - encode/decode for abcde
ok - encode/decode for Кудыкины горы
ok - encode/decode for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ok - encode/decode for $a $
ok - encode/decode for $a $
ok - encode/decode for $a\t $
ok - encode/decode for $a\\t $
# string: end
ok - string
# nil
Expand Down Expand Up @@ -278,13 +282,15 @@ ok - ucdata
# compact: end
ok - compact
# output
1..6
1..8
ok - encode for true
ok - decode for 'yes'
ok - encode for false
ok - decode for 'no'
ok - encode for nil
ok - decode for ~
ok - encode for binary
ok - tutorial string
# output: end
ok - output
# yaml: end
8 changes: 6 additions & 2 deletions test/app/yaml.test.lua
Expand Up @@ -34,21 +34,25 @@ local function test_compact(test, s)
test:is(ss.encode(setmetatable({k = 'v'}, { __serialize="mapping"})),
"---\nk: v\n...\n", "block map")
test:is(ss.encode({setmetatable({k = 'v'}, { __serialize="map"})}),
"---\n- {k: v}\n...\n", "flow map")
"---\n- {'k': 'v'}\n...\n", "flow map")
test:is(getmetatable(ss.decode(ss.encode({k = 'v'}))).__serialize, "map",
"decoded __serialize is map")

ss = nil
end

local function test_output(test, s)
test:plan(6)
test:plan(8)
test:is(s.encode({true}), '---\n- true\n...\n', "encode for true")
test:is(s.decode("---\nyes\n..."), true, "decode for 'yes'")
test:is(s.encode({false}), '---\n- false\n...\n', "encode for false")
test:is(s.decode("---\nno\n..."), false, "decode for 'no'")
test:is(s.encode({s.NULL}), '---\n- null\n...\n', "encode for nil")
test:is(s.decode("---\n~\n..."), s.NULL, "decode for ~")
test:is(s.encode("\x80\x92\xe8s\x16"), '--- !!binary gJLocxY=\n...\n',
"encode for binary")
test:is(s.encode("Tutorial -- Header\n====\n\nText"),
"--- |-\n Tutorial -- Header\n ====\n\n Text\n...\n", "tutorial string");
end

tap.test("yaml", function(test)
Expand Down
29 changes: 8 additions & 21 deletions test/box/net.box.result
Expand Up @@ -106,9 +106,9 @@ cn:eval('return ...', 1, 2, 3)
...
cn:eval('return { k = "v1" }, true, { xx = 10, yy = 15 }, nil')
---
- {k: v1}
- {'k': 'v1'}
- true
- {yy: 15, xx: 10}
- {'yy': 15, 'xx': 10}
- null
...
cn:eval('return nil')
Expand Down Expand Up @@ -632,41 +632,28 @@ cnc.console ~= nil
...
cnc:console('return 1, 2, 3, "string", nil')
---
- '---

- |
---
- 1

- 2

- 3

- string

- null

...

'
...
cnc:console('error("test")')
---
- '---

- |
---
- error: test

...

'
...
cnc:console('a = {1, 2, 3, 4}; return a[3]')
---
- '---

- |
---
- 3

...

'
...
-- #545 user or password is not defined
remote:new(LISTEN.host, LISTEN.service, { user = 'test' })
Expand Down
1 change: 1 addition & 0 deletions third_party/lua-yaml/LICENSE
@@ -1,4 +1,5 @@
Copyright (c) 2009, Andrew Danforth
Copyright (c) 2013-2015, Tarantool Authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down

0 comments on commit e0d3f3f

Please sign in to comment.