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:
nikita.hohlov
2026-09-04 08:25:00 -03:00
parent 027c9f7784
commit 86b02f3d36
4 changed files with 46 additions and 2 deletions

View File

@@ -83,6 +83,19 @@ class ClientApiTest extends TestCase
->assertStatus(422)->assertJsonValidationErrors(['events']);
}
public function test_deep_link_must_be_relative_or_http(): void
{
$bad = $this->item(['payload' => ['title' => 'x', 'deep_link' => 'javascript:alert(1)']]);
$this->putJson('/api/events', ['events' => [$bad]], $this->auth())
->assertStatus(422)->assertJsonValidationErrors(['events.0.payload.deep_link']);
$ok1 = $this->item(['payload' => ['title' => 'x', 'deep_link' => '/people/42']]);
$this->putJson('/api/events', ['events' => [$ok1]], $this->auth())->assertOk();
$ok2 = $this->item(['topic' => 'birthday:2027', 'payload' => ['title' => 'x', 'deep_link' => 'https://docs.example/x']]);
$this->putJson('/api/events', ['events' => [$ok2]], $this->auth())->assertOk();
}
public function test_topic_defaults_to_empty_string(): void
{
$item = $this->item();