@@ -177,7 +177,9 @@ protected function compileExtensions($value)
177177 */
178178 protected function compileComments ($ value )
179179 {
180- $ pattern = sprintf ('/%s--((.|\s)*?)--%s/ ' , $ this ->contentTags [0 ], $ this ->contentTags [1 ]);
180+ $ contentTags = $ this ->quoteTags ($ this ->contentTags );
181+
182+ $ pattern = sprintf ('/%s--((.|\s)*?)--%s/ ' , $ contentTags [0 ], $ contentTags [1 ]);
181183
182184 return preg_replace ($ pattern , '<?php /*$1*/ ?> ' , $ value );
183185 }
@@ -190,7 +192,11 @@ protected function compileComments($value)
190192 */
191193 protected function compileEchos ($ value )
192194 {
193- $ difference = strlen ($ this ->contentTags [0 ]) - strlen ($ this ->escapedTags [0 ]);
195+ $ contentTags = $ this ->quoteTags ($ this ->contentTags );
196+
197+ $ escapedTags = $ this ->quoteTags ($ this ->escapedTags );
198+
199+ $ difference = strlen ($ contentTags [0 ]) - strlen ($ escapedTags [0 ]);
194200
195201 if ($ difference > 0 )
196202 {
@@ -229,7 +235,9 @@ protected function compileStatements($value)
229235 */
230236 protected function compileRegularEchos ($ value )
231237 {
232- $ pattern = sprintf ('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s ' , $ this ->contentTags [0 ], $ this ->contentTags [1 ]);
238+ $ contentTags = $ this ->quoteTags ($ this ->contentTags );
239+
240+ $ pattern = sprintf ('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s ' , $ contentTags [0 ], $ contentTags [1 ]);
233241
234242 $ callback = function ($ matches )
235243 {
@@ -249,7 +257,9 @@ protected function compileRegularEchos($value)
249257 */
250258 protected function compileEscapedEchos ($ value )
251259 {
252- $ pattern = sprintf ('/%s\s*(.+?)\s*%s(\r?\n)?/s ' , $ this ->escapedTags [0 ], $ this ->escapedTags [1 ]);
260+ $ escapedTags = $ this ->quoteTags ($ this ->escapedTags );
261+
262+ $ pattern = sprintf ('/%s\s*(.+?)\s*%s(\r?\n)?/s ' , $ escapedTags [0 ], $ escapedTags [1 ]);
253263
254264 $ callback = function ($ matches )
255265 {
@@ -676,7 +686,7 @@ public function setContentTags($openTag, $closeTag, $escaped = false)
676686 {
677687 $ property = ($ escaped === true ) ? 'escapedTags ' : 'contentTags ' ;
678688
679- $ this ->{$ property } = array (preg_quote ( $ openTag), preg_quote ( $ closeTag) );
689+ $ this ->{$ property } = array ($ openTag, $ closeTag );
680690 }
681691
682692 /**
@@ -711,4 +721,18 @@ public function getEscapedContentTags()
711721 return $ this ->escapedTags ;
712722 }
713723
724+ /**
725+ * Quote tags.
726+ *
727+ * @param array $tags
728+ * @return array
729+ */
730+ protected function quoteTags ($ tags )
731+ {
732+ return [
733+ preg_quote ($ tags [0 ]),
734+ preg_quote ($ tags [1 ]),
735+ ];
736+ }
737+
714738}
0 commit comments