generate the Exp::CR() to support the escape of CR.

This commit is contained in:
dota17 2020-07-01 15:45:10 +08:00
parent a03368ad20
commit af1cc6c549
2 changed files with 7 additions and 3 deletions

View File

@ -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::CR();
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::CR();
const RegEx& disallowed = const RegEx& disallowed =
flowType == FlowType::Flow ? disallowed_flow : disallowed_block; flowType == FlowType::Flow ? disallowed_flow : disallowed_block;

View File

@ -32,6 +32,10 @@ inline const RegEx& Tab() {
static const RegEx e = RegEx('\t'); static const RegEx e = RegEx('\t');
return e; return e;
} }
inline const RegEx& CR() {
static const RegEx e = RegEx('\r');
return e;
}
inline const RegEx& Blank() { inline const RegEx& Blank() {
static const RegEx e = Space() | Tab(); static const RegEx e = Space() | Tab();
return e; return e;
@ -69,7 +73,7 @@ inline const RegEx& Hex() {
inline const RegEx& NotPrintable() { inline const RegEx& NotPrintable() {
static const RegEx e = static const RegEx e =
RegEx(0) | RegEx(0) |
RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x7F", REGEX_OR) | RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x7F", REGEX_OR) |
RegEx(0x0E, 0x1F) | RegEx(0x0E, 0x1F) |
(RegEx('\xC2') + (RegEx('\x80', '\x84') | RegEx('\x86', '\x9F'))); (RegEx('\xC2') + (RegEx('\x80', '\x84') | RegEx('\x86', '\x9F')));
return e; return e;