Skip to content

Commit

Permalink
Fix single cr not recognized (jbeder#1094)
Browse files Browse the repository at this point in the history
Complies with YAML Standard [5.4](https://yaml.org/spec/1.2.2/#54-line-break-characters) [25] instead of matching `\r` only in combination with `\n`.
  • Loading branch information
vehre-x41 authored Apr 1, 2022
1 parent 669af4e commit a6db7e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/exp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ inline const RegEx& Blank() {
return e;
}
inline const RegEx& Break() {
static const RegEx e = RegEx('\n') | RegEx("\r\n");
static const RegEx e = RegEx('\n') | RegEx("\r");
return e;
}
inline const RegEx& BlankOrBreak() {
Expand Down
8 changes: 8 additions & 0 deletions test/integration/emitter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,14 @@ TEST_F(EmitterTest, UserType) {
ExpectEmit("- x: 5\n bar: hello\n- x: 3\n bar: goodbye");
}

TEST_F(EmitterTest, UserType2) {
out << BeginSeq;
out << Foo(5, "\r");
out << EndSeq;

ExpectEmit("- x: 5\n bar: \"\\r\"");
}

TEST_F(EmitterTest, UserTypeInContainer) {
std::vector<Foo> fv;
fv.push_back(Foo(5, "hello"));
Expand Down

0 comments on commit a6db7e3

Please sign in to comment.