From bfb1774e78306fb4345c01a00f7a4fee5485d2e9 Mon Sep 17 00:00:00 2001 From: Brandon Surowiec Date: Thu, 14 Apr 2022 09:47:10 -0400 Subject: [PATCH] [9.x] Fix PHP warnings when rendering long blade string (#41956) (#41970) * [9.x] Fix PHP warnings when rendering long blade string (#41745) * Apply fixes from StyleCI (cherry picked from commit bb0da4a58a49fdb81e17c7b5ee364a515b015f33) Co-authored-by: Andrew Bashtannik --- src/Illuminate/View/Component.php | 2 +- tests/Integration/View/BladeTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/View/Component.php b/src/Illuminate/View/Component.php index 402a13abdc53..8acf9a7f874d 100644 --- a/src/Illuminate/View/Component.php +++ b/src/Illuminate/View/Component.php @@ -75,7 +75,7 @@ public function resolveView() $resolver = function ($view) { $factory = Container::getInstance()->make('view'); - return $factory->exists($view) + return strlen($view) <= PHP_MAXPATHLEN && $factory->exists($view) ? $view : $this->createBladeViewFromString($factory, $view); }; diff --git a/tests/Integration/View/BladeTest.php b/tests/Integration/View/BladeTest.php index 9f3717c4d818..b3d8f51eedc7 100644 --- a/tests/Integration/View/BladeTest.php +++ b/tests/Integration/View/BladeTest.php @@ -14,6 +14,15 @@ public function test_rendering_blade_string() $this->assertSame('Hello Taylor', Blade::render('Hello {{ $name }}', ['name' => 'Taylor'])); } + public function test_rendering_blade_long_maxpathlen_string() + { + $longString = str_repeat('a', PHP_MAXPATHLEN); + + $result = Blade::render($longString.'{{ $name }}', ['name' => 'a']); + + $this->assertSame($longString.'a', $result); + } + public function test_rendering_blade_component_instance() { $component = new HelloComponent('Taylor');