Skip to content

Commit

Permalink
fix issue #258
Browse files Browse the repository at this point in the history
  • Loading branch information
Herringway authored and dlang-bot committed Sep 19, 2020
1 parent fb6d30e commit bd549ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions source/dyaml/loader.d
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,11 @@ struct Loader

auto rootNode = loader.load();
}

//Issue #258 - https://github.com/dlang-community/D-YAML/issues/258
@safe unittest
{
auto yaml = "{\n\"root\": {\n\t\"key\": \"value\"\n }\n}";
auto doc = Loader.fromString(yaml).load();
assert(doc.isValid);
}
14 changes: 12 additions & 2 deletions source/dyaml/scanner.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ alias isBreakOrSpace = among!(' ', '\0', '\n', '\r', '\u0085', '\u2028', '\u2029

alias isWhiteSpace = among!(' ', '\t', '\0', '\n', '\r', '\u0085', '\u2028', '\u2029');

alias isNonLinebreakWhitespace = among!(' ', '\t');

alias isNonScalarStartCharacter = among!('-', '?', ':', ',', '[', ']', '{', '}',
'#', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`', ' ', '\t', '\0', '\n',
'\r', '\u0085', '\u2028', '\u2029');
Expand Down Expand Up @@ -800,8 +802,16 @@ struct Scanner

for(;;)
{
findNextNonSpace();

//All whitespace in flow context is ignored, even whitespace
// not allowed in other contexts
if (flowLevel_ > 0)
{
while(reader_.peekByte().isNonLinebreakWhitespace) { reader_.forward(); }
}
else
{
findNextNonSpace();
}
if(reader_.peekByte() == '#') { scanToNextBreak(); }
if(scanLineBreak() != '\0')
{
Expand Down

0 comments on commit bd549ca

Please sign in to comment.