Commit 6d0f72f
authored
Fix panic in Set Delimiter parsing. (#91)
* Fix panic in Set Delimiter parsing.
Mustache supports Set Delimter tags, of the form `{{=<open tag> <close tag>=}}`,
which is used to change the delimiters from `{{` and `}}`. Prior to this
commit, if there was a sequence that looked like the start of a Set
Delimiter tag, but there was not a complete Set Delimiter tag, the
library could panic.
This commit:
* factors out the Set Delimiter tag parsing into a new function,
'parseCustomDelimiter()'
* adds checks to make sure an incomplete tag doesn't cause an access
off the end of a slice
* treats an incomplete Set Delimiter (like `{{=}}`) as a normaal
tag
This behaviour matches the mustache playground at
https://jgonggrijp.gitlab.io/wontache/playground.html. I tried to match
the behaviour of the Ruby implementation, but it seems to be
inconsistent in this case.
* Remove checks that are no inside parseCustomDelimiter()
The parse() method contains a check for 'unbalanced' custom
delimiter tags (i.e. tags that start with {{=, but don't have a
matching closing tag), and throws an error. However, wit the
new custom delimiter fix, those tags are treated as normal tags.
For example, `{{= %}}` is interpreted as a tag named `= %`, not
a malformed custom delimiter tag.
This commit removes the extra check that returns an error.1 parent d50b8fb commit 6d0f72f
2 files changed
+23
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
| 377 | + | |
386 | 378 | | |
387 | 379 | | |
388 | 380 | | |
| |||
445 | 437 | | |
446 | 438 | | |
447 | 439 | | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 440 | + | |
457 | 441 | | |
458 | 442 | | |
459 | 443 | | |
| |||
469 | 453 | | |
470 | 454 | | |
471 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
472 | 471 | | |
473 | 472 | | |
474 | 473 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
0 commit comments