Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Improved check on long Blade strings #43594

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/View/Component.php
Expand Up @@ -74,7 +74,7 @@ public function resolveView()
$resolver = function ($view) {
$factory = Container::getInstance()->make('view');

return strlen($view) <= PHP_MAXPATHLEN && $factory->exists($view)
return $factory->exists($view)
? $view
: $this->createBladeViewFromString($factory, $view);
};
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/View/FileViewFinder.php
Expand Up @@ -128,7 +128,8 @@ protected function findInPaths($name, $paths)
{
foreach ((array) $paths as $path) {
foreach ($this->getPossibleViewFiles($name) as $file) {
if ($this->files->exists($viewPath = $path.'/'.$file)) {
$viewPath = $path.'/'.$file;
if (strlen($viewPath) <= PHP_MAXPATHLEN && $this->files->exists($viewPath)) {
return $viewPath;
}
}
Expand Down
23 changes: 23 additions & 0 deletions tests/Integration/View/BladeTest.php
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
use Illuminate\View\Component;
use Orchestra\Testbench\TestCase;

Expand All @@ -30,6 +31,13 @@ public function test_rendering_blade_component_instance()
$this->assertSame('Hello Taylor', Blade::renderComponent($component));
}

public function test_rendering_large_blade_component_instance()
{
$component = new LargeComponent();

$this->assertSame($component->contents, Blade::renderComponent($component));
}

public function test_basic_blade_rendering()
{
$view = View::make('hello', ['name' => 'Taylor'])->render();
Expand Down Expand Up @@ -142,3 +150,18 @@ public function render()
return 'Hello {{ $name }}';
}
}

class LargeComponent extends Component
{
public $contents;

public function __construct()
{
$this->contents = Str::random(PHP_MAXPATHLEN);
}

public function render()
{
return $this->contents;
}
}