diff --git a/src/Handlebars/Tokenizer.php b/src/Handlebars/Tokenizer.php index 2ff7dc3..63488cc 100644 --- a/src/Handlebars/Tokenizer.php +++ b/src/Handlebars/Tokenizer.php @@ -127,7 +127,7 @@ class Tokenizer $this->escaping = $this->tagChange(self::T_ESCAPE, $text, $i); - if ( $this->escaped and $text[$i + 1] != self::T_UNESCAPED ) { + if ( $this->escaped and $text[$i] != self::T_UNESCAPED ) { $this->buffer .= "\\"; } @@ -142,7 +142,7 @@ class Tokenizer $this->flushBuffer(); $this->state = self::IN_TAG_TYPE; } elseif ($this->escaped and $this->escaping) { - $this->buffer .= "\\\\"; + $this->buffer .= "\\"; } elseif (!$this->escaping) { if ($text[$i] == "\n") { $this->filterLine(); diff --git a/tests/Xamin/HandlebarsTest.php b/tests/Xamin/HandlebarsTest.php index bde8785..93418d0 100644 --- a/tests/Xamin/HandlebarsTest.php +++ b/tests/Xamin/HandlebarsTest.php @@ -142,6 +142,11 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase array(), '\pi' ), + array( + '\\\\\\\\qux', + array(), + '\\\\\\\\qux' + ), ); }