From b7f2c692df723daa5fb88b94d252814f28a82dd0 Mon Sep 17 00:00:00 2001 From: Duilio Palacios Date: Thu, 16 Feb 2017 13:52:24 +0000 Subject: [PATCH] Compile Blade comments first in order to prevent Blade from compiling statements inside comments (#17952) --- src/Illuminate/View/Compilers/BladeCompiler.php | 2 +- tests/View/Blade/BladeCommentsTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/View/Compilers/BladeCompiler.php b/src/Illuminate/View/Compilers/BladeCompiler.php index 1ebf4f9ee12b..e11731e8afe6 100644 --- a/src/Illuminate/View/Compilers/BladeCompiler.php +++ b/src/Illuminate/View/Compilers/BladeCompiler.php @@ -49,9 +49,9 @@ class BladeCompiler extends Compiler implements CompilerInterface * @var array */ protected $compilers = [ + 'Comments', 'Extensions', 'Statements', - 'Comments', 'Echos', ]; diff --git a/tests/View/Blade/BladeCommentsTest.php b/tests/View/Blade/BladeCommentsTest.php index 4cdd93b9fb8c..bcba2f162954 100644 --- a/tests/View/Blade/BladeCommentsTest.php +++ b/tests/View/Blade/BladeCommentsTest.php @@ -28,6 +28,14 @@ public function testCommentsAreCompiled() $this->assertEmpty($compiler->compileString($string)); } + public function testBladeCodeInsideCommentsIsNotCompiled() + { + $compiler = new BladeCompiler($this->getFiles(), __DIR__); + $string = '{{-- @foreach() --}}'; + + $this->assertEmpty($compiler->compileString($string)); + } + protected function getFiles() { return m::mock('Illuminate\Filesystem\Filesystem');