Merge pull request #905 from jonnybarnes/904-specific-notes-link-causing-numeric-value-out-of-range-sql-error
refactor: Improve note ID validation and error handling
This commit is contained in:
commit
7edac37e16
3 changed files with 14 additions and 0 deletions
|
@ -286,6 +286,13 @@ class Note extends Model
|
|||
*/
|
||||
public function scopeNb60(Builder $query, string $nb60id): Builder
|
||||
{
|
||||
$realId = resolve(Numbers::class)->b60tonum($nb60id);
|
||||
|
||||
// Check nb60 does not translate to ID too big for database int4 column
|
||||
if ($realId > 2_147_483_647) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return $query->where('id', resolve(Numbers::class)->b60tonum($nb60id));
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -73,4 +73,11 @@ class NotesControllerTest extends TestCase
|
|||
$response = $this->get('/notes/112233');
|
||||
$response->assertNotFound();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function checkNoteIdNotOutOfRange(): void
|
||||
{
|
||||
$response = $this->get('/notes/photou-photologo');
|
||||
$response->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue