Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
600de460
Commit
600de460
authored
9 years ago
by
Nick Zavaritsky
Committed by
Roman Tsisyk
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix #354: yaml incorrectly escapes special characters in a string
parent
09c0c240
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/app/yaml.result
+2
-1
2 additions, 1 deletion
test/app/yaml.result
test/app/yaml.test.lua
+3
-1
3 additions, 1 deletion
test/app/yaml.test.lua
third_party/lua-yaml/lyaml.cc
+18
-1
18 additions, 1 deletion
third_party/lua-yaml/lyaml.cc
with
23 additions
and
3 deletions
test/app/yaml.result
+
2
−
1
View file @
600de460
...
...
@@ -271,7 +271,7 @@ ok - ucdata
# compact: end
ok - compact
# output
1..
8
1..
9
ok - encode for true
ok - decode for 'yes'
ok - encode for false
...
...
@@ -279,6 +279,7 @@ ok - compact
ok - encode for nil
ok - decode for ~
ok - encode for binary
ok - encode for binary (2) - gh-354
ok - tutorial string
# output: end
ok - output
...
...
This diff is collapsed.
Click to expand it.
test/app/yaml.test.lua
+
3
−
1
View file @
600de460
...
...
@@ -42,7 +42,7 @@ local function test_compact(test, s)
end
local
function
test_output
(
test
,
s
)
test
:
plan
(
8
)
test
:
plan
(
9
)
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"
)
...
...
@@ -51,6 +51,8 @@ local function test_output(test, s)
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
(
"\x08\x5c\xc2\x80\x12\x2f"
),
'--- !!binary CFzCgBIv\n...\n'
,
"encode for binary (2) - gh-354"
)
test
:
is
(
s
.
encode
(
"Tutorial -- Header\n====\n\nText"
),
"--- |-\n Tutorial -- Header\n ====\n\n Text\n...\n"
,
"tutorial string"
);
end
...
...
This diff is collapsed.
Click to expand it.
third_party/lua-yaml/lyaml.cc
+
18
−
1
View file @
600de460
...
...
@@ -44,6 +44,7 @@ extern "C" {
#include
<lj_state.h>
#include
"yaml.h"
#include
"yaml_private.h"
#include
"b64.h"
}
/* extern "C" */
#include
"lua/utils.h"
...
...
@@ -515,8 +516,24 @@ static yaml_scalar_style_t analyze_string(struct lua_yaml_dumper *dumper,
return
YAML_PLAIN_SCALAR_STYLE
;
}
/* Truncated UTF-8 sequence? */
if
(
p
+
continuation_bytes
>=
e
)
{
*
is_binary
=
1
;
return
YAML_PLAIN_SCALAR_STYLE
;
}
/*
* Valid non-printable UTF-8? Encode as binary since otherwise
* the conversion may be lossy, ex: '\xc2\x80' -> '\x80'.
*/
yaml_string_t
ys
;
ys
.
pointer
=
(
yaml_char_t
*
)
p
;
if
(
!
IS_PRINTABLE
(
ys
))
{
*
is_binary
=
1
;
return
YAML_PLAIN_SCALAR_STYLE
;
}
++
p
;
while
(
p
<
e
&&
continuation_bytes
>
0
&&
*
p
>=
0x80
&&
*
p
<=
0xBF
)
{
while
(
continuation_bytes
>
0
&&
*
p
>=
0x80
&&
*
p
<=
0xBF
)
{
++
p
;
continuation_bytes
-=
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment