Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/StaticCaching/NoCache/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function context(): array
protected function filterContext(array $context)
{
$context = collect($context)
->reject(fn ($value, $key) => in_array($key, ['__env', 'app', 'errors', 'resolve', 'resolveComponentsUsing', 'forgetComponentsResolver', 'forgetFactory', 'flushCache', 'constructor']))
->reject(fn ($value, $key) => str_starts_with((string) $key, '__'))
->reject(fn ($value, $key) => in_array($key, ['app', 'errors', 'resolve', 'resolveComponentsUsing', 'forgetComponentsResolver', 'forgetFactory', 'flushCache', 'constructor']))
->map(function ($value, $key) {
if ($value instanceof InvokableComponentVariable) {
return $value->resolveDisplayableValue();
Expand Down
16 changes: 16 additions & 0 deletions tests/StaticCaching/NoCacheSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ public function when_pushing_a_region_it_will_filter_out_cascade()
], $region->context());
}

#[Test]
public function when_pushing_a_region_it_will_filter_out_private_variables()
{
$session = new Session('/');

$region = $session->pushRegion('', [
'foo' => 'bar',
'__env' => 'env value',
'__blaze' => fn () => 'a closure',
], '');

$this->assertEquals([
'foo' => 'bar',
], $region->context());
}

#[Test]
public function it_gets_the_fragment_data()
{
Expand Down
Loading