Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
51ce6630
Unverified
Commit
51ce6630
authored
Jul 16, 2020
by
Chen
Committed by
GitHub
Jul 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle a key with length over 1024 as a long key. (#916)
Fixes #501
parent
33315286
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
src/emitter.cpp
+1
-1
test/integration/emitter_test.cpp
+8
-1
No files found.
src/emitter.cpp
View file @
51ce6630
...
...
@@ -708,7 +708,7 @@ Emitter& Emitter::Write(const std::string& str) {
Utils
::
ComputeStringFormat
(
str
,
m_pState
->
GetStringFormat
(),
m_pState
->
CurGroupFlowType
(),
stringEscaping
==
StringEscaping
::
NonAscii
);
if
(
strFormat
==
StringFormat
::
Literal
)
if
(
strFormat
==
StringFormat
::
Literal
||
str
.
size
()
>
1024
)
m_pState
->
SetMapKeyFormat
(
YAML
::
LongKey
,
FmtScope
::
Local
);
PrepareNode
(
EmitterNodeType
::
Scalar
);
...
...
test/integration/emitter_test.cpp
View file @
51ce6630
...
...
@@ -266,6 +266,8 @@ TEST_F(EmitterTest, SimpleLongKey) {
}
TEST_F
(
EmitterTest
,
SingleLongKey
)
{
const
std
::
string
shortKey
(
1024
,
'a'
);
const
std
::
string
longKey
(
1025
,
'a'
);
out
<<
BeginMap
;
out
<<
Key
<<
"age"
;
out
<<
Value
<<
"24"
;
...
...
@@ -273,9 +275,14 @@ TEST_F(EmitterTest, SingleLongKey) {
out
<<
Value
<<
"5'9
\"
"
;
out
<<
Key
<<
"weight"
;
out
<<
Value
<<
145
;
out
<<
Key
<<
shortKey
;
out
<<
Value
<<
"1"
;
out
<<
Key
<<
longKey
;
out
<<
Value
<<
"1"
;
out
<<
EndMap
;
ExpectEmit
(
"age: 24
\n
? height
\n
: 5'9
\"\n
weight: 145"
);
ExpectEmit
(
"age: 24
\n
? height
\n
: 5'9
\"\n
weight: 145
\n
"
+
shortKey
+
": 1
\n
? "
+
longKey
+
"
\n
: 1"
);
}
TEST_F
(
EmitterTest
,
ComplexLongKey
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment