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
13626af9
Unverified
Commit
13626af9
authored
Apr 21, 2022
by
Dr. Andre Vehreschild
Committed by
GitHub
Apr 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix escaping anchors in keys (#1101)
parent
4c982d59
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
src/emitterutils.cpp
+2
-2
src/exp.h
+4
-0
test/integration/emitter_test.cpp
+10
-0
No files found.
src/emitterutils.cpp
View file @
13626af9
...
@@ -176,11 +176,11 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
...
@@ -176,11 +176,11 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
static
const
RegEx
&
disallowed_flow
=
static
const
RegEx
&
disallowed_flow
=
Exp
::
EndScalarInFlow
()
|
(
Exp
::
BlankOrBreak
()
+
Exp
::
Comment
())
|
Exp
::
EndScalarInFlow
()
|
(
Exp
::
BlankOrBreak
()
+
Exp
::
Comment
())
|
Exp
::
NotPrintable
()
|
Exp
::
Utf8_ByteOrderMark
()
|
Exp
::
Break
()
|
Exp
::
NotPrintable
()
|
Exp
::
Utf8_ByteOrderMark
()
|
Exp
::
Break
()
|
Exp
::
Tab
();
Exp
::
Tab
()
|
Exp
::
Ampersand
()
;
static
const
RegEx
&
disallowed_block
=
static
const
RegEx
&
disallowed_block
=
Exp
::
EndScalar
()
|
(
Exp
::
BlankOrBreak
()
+
Exp
::
Comment
())
|
Exp
::
EndScalar
()
|
(
Exp
::
BlankOrBreak
()
+
Exp
::
Comment
())
|
Exp
::
NotPrintable
()
|
Exp
::
Utf8_ByteOrderMark
()
|
Exp
::
Break
()
|
Exp
::
NotPrintable
()
|
Exp
::
Utf8_ByteOrderMark
()
|
Exp
::
Break
()
|
Exp
::
Tab
();
Exp
::
Tab
()
|
Exp
::
Ampersand
()
;
const
RegEx
&
disallowed
=
const
RegEx
&
disallowed
=
flowType
==
FlowType
::
Flow
?
disallowed_flow
:
disallowed_block
;
flowType
==
FlowType
::
Flow
?
disallowed_flow
:
disallowed_block
;
...
...
src/exp.h
View file @
13626af9
...
@@ -117,6 +117,10 @@ inline const RegEx& ValueInJSONFlow() {
...
@@ -117,6 +117,10 @@ inline const RegEx& ValueInJSONFlow() {
static
const
RegEx
e
=
RegEx
(
':'
);
static
const
RegEx
e
=
RegEx
(
':'
);
return
e
;
return
e
;
}
}
inline
const
RegEx
&
Ampersand
()
{
static
const
RegEx
e
=
RegEx
(
'&'
);
return
e
;
}
inline
const
RegEx
Comment
()
{
inline
const
RegEx
Comment
()
{
static
const
RegEx
e
=
RegEx
(
'#'
);
static
const
RegEx
e
=
RegEx
(
'#'
);
return
e
;
return
e
;
...
...
test/integration/emitter_test.cpp
View file @
13626af9
...
@@ -1624,6 +1624,15 @@ NodeB:
...
@@ -1624,6 +1624,15 @@ NodeB:
k: [*k0, *k1])"
);
k: [*k0, *k1])"
);
}
}
TEST_F
(
EmitterTest
,
AnchorEncoding
)
{
Node
node
;
node
[
"--- &$ [*$]1"
]
=
1
;
out
<<
node
;
ExpectEmit
(
"
\"
--- &$ [*$]1
\"
: 1"
);
Node
reparsed
=
YAML
::
Load
(
out
.
c_str
());
EXPECT_EQ
(
reparsed
[
"--- &$ [*$]1"
].
as
<
int
>
(),
1
);
}
class
EmitterErrorTest
:
public
::
testing
::
Test
{
class
EmitterErrorTest
:
public
::
testing
::
Test
{
protected
:
protected
:
void
ExpectEmitError
(
const
std
::
string
&
expectedError
)
{
void
ExpectEmitError
(
const
std
::
string
&
expectedError
)
{
...
@@ -1694,5 +1703,6 @@ TEST_F(EmitterErrorTest, InvalidAlias) {
...
@@ -1694,5 +1703,6 @@ TEST_F(EmitterErrorTest, InvalidAlias) {
ExpectEmitError
(
ErrorMsg
::
INVALID_ALIAS
);
ExpectEmitError
(
ErrorMsg
::
INVALID_ALIAS
);
}
}
}
// namespace
}
// namespace
}
// namespace YAML
}
// namespace YAML
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