Skip to content

Commit b131766

Browse files
jasonvargaclaude
andcommitted
Only accept string or strict integer connection ids in the connector editor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c90ff96 commit b131766

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/Http/Controllers/CP/Forms/FormConnectController.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function editor(Request $request, $form, string $handle)
9191
// Only check the shape. Stored connections that fail the connector's rules must still open so they can be fixed.
9292
Validator::make($request->all(), [
9393
'*' => ['array'],
94-
'*.id' => ['nullable', Rule::anyOf(['string', 'integer'])],
94+
'*.id' => ['nullable', Rule::anyOf(['string', 'integer:strict'])],
9595
'*.enabled' => ['nullable', 'boolean'],
9696
'*.conditions' => ['nullable', 'array'],
9797
'*.conditions.*' => ['array'],

‎tests/Feature/Forms/ConnectorEditorTest.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function it_rejects_structurally_malformed_connections($connections, $err
8383

8484
$this
8585
->actingAs($user)
86-
->postJson(cp_route('forms.connect.editor', [$form->handle(), 'grid_test']), $connections)
86+
->postJson(cp_route('forms.connect.editor', [$form->handle(), 'grid_test']), $connections, [], JSON_PRESERVE_ZERO_FRACTION)
8787
->assertUnprocessable()
8888
->assertJsonValidationErrors($errorKey);
8989
}
@@ -93,6 +93,8 @@ public static function malformedConnectionsProvider()
9393
return [
9494
'non-array connection' => [['x'], '0'],
9595
'array id' => [[['id' => ['a']]], '0.id'],
96+
'boolean id' => [[['id' => true]], '0.id'],
97+
'float id' => [[['id' => 1.0]], '0.id'],
9698
'non-boolean enabled' => [[['enabled' => 'x']], '0.enabled'],
9799
'non-array conditions' => [[['conditions' => 'x']], '0.conditions'],
98100
'non-array condition row' => [[['conditions' => ['x']]], '0.conditions.0'],

0 commit comments

Comments
 (0)