Handle a key with length over 1024 as a long key. (#916)

Fixes #501
This commit is contained in:
Chen
2020-07-16 22:51:54 +08:00
committed by GitHub
parent 33315286ab
commit 51ce663085
2 changed files with 9 additions and 2 deletions

View File

@@ -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);