fix: restrict deep_link to relative paths and http(s)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
@@ -88,4 +88,22 @@ class InboxPageTest extends TestCase
|
||||
$this->assertStringContainsString('<title>Hado</title>', $html);
|
||||
$this->assertStringNotContainsString('class="counter"', $html);
|
||||
}
|
||||
|
||||
public function test_unsafe_deep_link_is_not_rendered_as_href(): void
|
||||
{
|
||||
$this->get('/', ['X-Remote-User' => 'nikita']);
|
||||
$user = User::sole();
|
||||
$source = Source::create(['name' => 'docs', 'token_hash' => hash('sha256', 'x')]);
|
||||
Event::create([
|
||||
'source_id' => $source->id, 'user_id' => $user->id, 'source_ref' => 'r', 'topic' => 'a',
|
||||
'due_mode' => DueMode::Local, 'due_date' => '2026-09-04', 'due_time' => '24:00:00', 'fire_on' => '2026-09-04',
|
||||
'after_due' => AfterDue::Keep, 'payload' => ['title' => 'Опасное событие', 'deep_link' => 'javascript:alert(1)'],
|
||||
'state' => EventState::Today, 'quiet_until' => CarbonImmutable::parse('2000-01-01Z'),
|
||||
]);
|
||||
|
||||
$html = $this->get('/', ['X-Remote-User' => 'nikita'])->assertOk()->getContent();
|
||||
|
||||
$this->assertStringNotContainsString('href="javascript:', $html);
|
||||
$this->assertStringContainsString('Опасное событие', $html);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user