From: ArthurHoaro Date: Wed, 28 Oct 2020 12:22:40 +0000 (+0100) Subject: Merge pull request #1613 from ArthurHoaro/hotfix/404-not-authorized X-Git-Tag: v0.12.1^2~21 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=d2bb40cc7ca2a7f9c2403087016a0050a7113e07;hp=06734af130e52eec5cb1fa51b26edebbfa4bc798;p=github%2Fshaarli%2FShaarli.git Merge pull request #1613 from ArthurHoaro/hotfix/404-not-authorized Raise 404 error instead of 500 if permalink access is denied --- diff --git a/application/bookmark/BookmarkFileService.php b/application/bookmark/BookmarkFileService.php index 0df2f47f..3ea98a45 100644 --- a/application/bookmark/BookmarkFileService.php +++ b/application/bookmark/BookmarkFileService.php @@ -106,7 +106,7 @@ class BookmarkFileService implements BookmarkServiceInterface && $first->isPrivate() && (empty($privateKey) || $privateKey !== $first->getAdditionalContentEntry('private_key')) ) { - throw new Exception('Not authorized'); + throw new BookmarkNotFoundException(); } return $first; diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index 8e0ff8dd..f619aff3 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -886,8 +886,8 @@ class BookmarkFileServiceTest extends TestCase */ public function testFilterHashPrivateWhileLoggedOut() { - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Not authorized'); + $this->expectException(BookmarkNotFoundException::class); + $this->expectExceptionMessage('The link you are trying to reach does not exist or has been deleted'); $hash = smallHash('20141125_084734' . 6);