From fafdf1711705fd11a370ae65bfe2278a8fb788f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Viande?= Date: Mon, 25 Sep 2017 19:34:42 +0200 Subject: [PATCH 1/4] Fix #3361 check type for tags in entry repository Check is $tags is a string before explode --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 05f0e0ba1..b5e35eff3 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -151,7 +151,7 @@ class EntryRepository extends EntityRepository $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); } - if ('' !== $tags) { + if (is_string($tags) && '' !== $tags) { foreach (explode(',', $tags) as $i => $tag) { $entryAlias = 'e' . $i; $tagAlias = 't' . $i; From d03b72f405095e4173dd07e6f38fe0cff23d36c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Viande?= Date: Tue, 26 Sep 2017 11:29:09 +0200 Subject: [PATCH 2/4] Fix #3361 add test --- .../ApiBundle/Controller/EntryRestControllerTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index fcec3f3b2..4ffe478da 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -308,6 +308,13 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); } + public function testGetTaggedEntriesWithBadParams() + { + $this->client->request('GET', '/api/entries', ['tags' => ['foo','bar']]); + + $this->assertSame(200, $this->client->getResponse()->getStatusCode()); + } + public function testGetDatedEntries() { $this->client->request('GET', '/api/entries', ['since' => 1443274283]); From bb86dc648660cf3d94c6800f97214426b52f2d8e Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 11 Oct 2017 10:51:24 +0200 Subject: [PATCH 3/4] CS --- tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 4ffe478da..95c64501c 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -310,7 +310,7 @@ class EntryRestControllerTest extends WallabagApiTestCase public function testGetTaggedEntriesWithBadParams() { - $this->client->request('GET', '/api/entries', ['tags' => ['foo','bar']]); + $this->client->request('GET', '/api/entries', ['tags' => ['foo', 'bar']]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); } From 0978bd849e77b1157b21f8e231965521e535bacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Viande?= Date: Thu, 12 Oct 2017 07:28:42 +0200 Subject: [PATCH 4/4] Fix #3361 Entry Rest controller getEntries cast tags params to string --- src/Wallabag/ApiBundle/Controller/EntryRestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 86e723351..6f161a081 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -102,7 +102,7 @@ class EntryRestController extends WallabagRestController $order = $request->query->get('order', 'desc'); $page = (int) $request->query->get('page', 1); $perPage = (int) $request->query->get('perPage', 30); - $tags = $request->query->get('tags', ''); + $tags = is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', ''); $since = $request->query->get('since', 0); /** @var \Pagerfanta\Pagerfanta $pager */