Skip to content

Commit d3c0a36

Browse files
committed
escape lang directive echos
1 parent 45daf1e commit d3c0a36

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Illuminate/View/Compilers/Concerns/CompilesTranslations.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function compileLang($expression)
1818
return "<?php \$__env->startTranslation{$expression}; ?>";
1919
}
2020

21-
return "<?php echo app('translator')->getFromJson{$expression}; ?>";
21+
return "<?php echo e(app('translator')->getFromJson{$expression}); ?>";
2222
}
2323

2424
/**
@@ -28,7 +28,7 @@ protected function compileLang($expression)
2828
*/
2929
protected function compileEndlang()
3030
{
31-
return '<?php echo $__env->renderTranslation(); ?>';
31+
return '<?php echo e($__env->renderTranslation()); ?>';
3232
}
3333

3434
/**
@@ -39,6 +39,6 @@ protected function compileEndlang()
3939
*/
4040
protected function compileChoice($expression)
4141
{
42-
return "<?php echo app('translator')->choice{$expression}; ?>";
42+
return "<?php echo e(app('translator')->choice{$expression}); ?>";
4343
}
4444
}

tests/View/Blade/BladeExpressionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ class BladeExpressionTest extends AbstractBladeTestCase
66
{
77
public function testExpressionsOnTheSameLine()
88
{
9-
$this->assertEquals('<?php echo app(\'translator\')->getFromJson(foo(bar(baz(qux(breeze()))))); ?> space () <?php echo app(\'translator\')->getFromJson(foo(bar)); ?>', $this->compiler->compileString('@lang(foo(bar(baz(qux(breeze()))))) space () @lang(foo(bar))'));
9+
$this->assertEquals('<?php echo e(app(\'translator\')->getFromJson(foo(bar(baz(qux(breeze())))))); ?> space () <?php echo e(app(\'translator\')->getFromJson(foo(bar))); ?>', $this->compiler->compileString('@lang(foo(bar(baz(qux(breeze()))))) space () @lang(foo(bar))'));
1010
}
1111

1212
public function testExpressionWithinHTML()
1313
{
1414
$this->assertEquals('<html <?php echo e($foo); ?>>', $this->compiler->compileString('<html {{ $foo }}>'));
1515
$this->assertEquals('<html<?php echo e($foo); ?>>', $this->compiler->compileString('<html{{ $foo }}>'));
16-
$this->assertEquals('<html <?php echo e($foo); ?> <?php echo app(\'translator\')->getFromJson(\'foo\'); ?>>', $this->compiler->compileString('<html {{ $foo }} @lang(\'foo\')>'));
16+
$this->assertEquals('<html <?php echo e($foo); ?> <?php echo e(app(\'translator\')->getFromJson(\'foo\')); ?>>', $this->compiler->compileString('<html {{ $foo }} @lang(\'foo\')>'));
1717
}
1818
}

tests/View/Blade/BladeLangTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ class BladeLangTest extends AbstractBladeTestCase
77
public function testStatementThatContainsNonConsecutiveParenthesisAreCompiled()
88
{
99
$string = "Foo @lang(function_call('foo(blah)')) bar";
10-
$expected = "Foo <?php echo app('translator')->getFromJson(function_call('foo(blah)')); ?> bar";
10+
$expected = "Foo <?php echo e(app('translator')->getFromJson(function_call('foo(blah)'))); ?> bar";
1111
$this->assertEquals($expected, $this->compiler->compileString($string));
1212
}
1313

1414
public function testLanguageAndChoicesAreCompiled()
1515
{
16-
$this->assertEquals('<?php echo app(\'translator\')->getFromJson(\'foo\'); ?>', $this->compiler->compileString("@lang('foo')"));
17-
$this->assertEquals('<?php echo app(\'translator\')->choice(\'foo\', 1); ?>', $this->compiler->compileString("@choice('foo', 1)"));
16+
$this->assertEquals('<?php echo e(app(\'translator\')->getFromJson(\'foo\')); ?>', $this->compiler->compileString("@lang('foo')"));
17+
$this->assertEquals('<?php echo e(app(\'translator\')->choice(\'foo\', 1)); ?>', $this->compiler->compileString("@choice('foo', 1)"));
1818
}
1919
}

0 commit comments

Comments
 (0)