Skip to content

Commit 3585d29

Browse files
authored
Merge pull request #536 from anth12/master
Fix 535 OutOfMemoryException
2 parents 64bf3a8 + 8dc42f6 commit 3585d29

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

source/Handlebars.Test/IssueTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,5 +723,15 @@ public void LastLetterCutOff()
723723

724724
Assert.Equal("abcd", templateOutput);
725725
}
726+
727+
// Issue: https://github.com/Handlebars-Net/Handlebars.Net/issues/535
728+
// Issue refers to invalid template causing OutOfMemoryException
729+
[Fact]
730+
public void UnrecognisedExpressionThrowsOutOfMemoryException()
731+
{
732+
var source = "{{Name | invalid}}";
733+
734+
Assert.Throws<HandlebarsCompilerException>(()=> Handlebars.Compile(source));
735+
}
726736
}
727737
}

source/Handlebars/Compiler/Lexer/Parsers/BlockParamsParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private static string AccumulateWord(ExtendedStringReader reader)
2323

2424
reader.Read();
2525

26-
while (reader.Peek() != '|')
26+
while (reader.Peek() != '|' && reader.Peek() != -1)
2727
{
2828
buffer.Append((char) reader.Read());
2929
}

0 commit comments

Comments
 (0)