@@ -6,6 +6,8 @@
|
||||
|
||||
- Fixes a potential crash when using the `{% for %}` template tag with the
|
||||
incorrect amount of arguments.
|
||||
- Fixes a potential crash when using incomplete tokens in a template for
|
||||
example, `{%%}` or `{{}}`.
|
||||
|
||||
|
||||
## 0.9.0
|
||||
|
||||
@@ -7,6 +7,7 @@ struct Lexer {
|
||||
|
||||
func createToken(string: String) -> Token {
|
||||
func strip() -> String {
|
||||
guard string.characters.count > 4 else { return "" }
|
||||
let start = string.index(string.startIndex, offsetBy: 2)
|
||||
let end = string.index(string.endIndex, offsetBy: -2)
|
||||
return string[start..<end].trim(character: " ")
|
||||
|
||||
@@ -54,5 +54,15 @@ func testLexer() {
|
||||
try expect(tokens[0]) == Token.variable(value: "thing")
|
||||
try expect(tokens[1]) == Token.variable(value: "name")
|
||||
}
|
||||
|
||||
$0.it("can tokenize an unclosed block") {
|
||||
let lexer = Lexer(templateString: "{%}")
|
||||
let _ = lexer.tokenize()
|
||||
}
|
||||
|
||||
$0.it("can tokenize an empty variable") {
|
||||
let lexer = Lexer(templateString: "{{}}")
|
||||
let _ = lexer.tokenize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user