Skip to content

Commit

Permalink
[8.x] Adds a small fix for unicode with blade echo handlers (#37697)
Browse files Browse the repository at this point in the history
* Adds a small fix for unicode with blade handlers.

* CS fixes

* CS fixes
  • Loading branch information
lukeraymonddowning authored Jun 15, 2021
1 parent 6a3254a commit e05968a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Illuminate/View/Compilers/Concerns/CompilesEchos.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,13 @@ protected function addBladeCompilerVariable($result)
*/
protected function wrapInEchoHandler($value)
{
return empty($this->echoHandlers) ? $value : '$__bladeCompiler->applyEchoHandler('.Str::beforeLast($value, ';').')';
$value = Str::of($value)
->trim()
->when(Str::endsWith($value, ';'), function ($str) {
return $str->beforeLast(';');
});

return empty($this->echoHandlers) ? $value : '$__bladeCompiler->applyEchoHandler('.$value.')';
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/View/Blade/BladeEchoHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function nonStringableDataProvider()
['{{"foo" . "bar"}}', 'foobar'],
['{{ 1 + 2 }}{{ "test"; }}', '3test'],
['@php($test = "hi"){{ $test }}', 'hi'],
['{!! " " !!}', ' '],
];
}
}

0 comments on commit e05968a

Please sign in to comment.