fix(for tag): Potential ‘Index out of range’ crash

Fixes #136
This commit is contained in:
Jan Berkel
2017-09-01 14:21:41 +02:00
committed by Kyle Fuller
parent 0444f45d2b
commit f1fc747897
3 changed files with 18 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ class ForNode : NodeType {
class func parse(_ parser:TokenParser, token:Token) throws -> NodeType {
let components = token.components()
guard components.count >= 2 && components[2] == "in" &&
guard components.count >= 3 && components[2] == "in" &&
(components.count == 4 || (components.count >= 6 && components[4] == "where")) else {
throw TemplateSyntaxError("'for' statements should use the following 'for x in y where condition' `\(token.contents)`.")
}