diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fc82cb71f..be862d750 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -53,12 +53,16 @@ class EntryController extends AbstractController
}
/**
- * @Route("/mass", name="mass_action")
+ * @Route("/mass", name="mass_action", methods={"POST"})
*
* @return Response
*/
public function massAction(Request $request, TagRepository $tagRepository)
{
+ if (!$this->isCsrfTokenValid('mass-action', $request->request->get('token'))) {
+ throw new BadRequestHttpException('Bad CSRF token.');
+ }
+
$values = $request->request->all();
$tagsToAdd = [];
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
index 95052adc6..a02094d42 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
@@ -26,7 +26,9 @@
{% if current_route == 'homepage' %}
{% set current_route = 'unread' %}
{% endif %}
-
{{ 'entry.list.number_on_the_page'|trans({'%count%': entries.count}) }}
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 237bd0af3..f8f47d8b7 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -1764,8 +1764,12 @@ class EntryControllerTest extends WallabagCoreTestCase
$entries[] = $entry1Id = $entry1->getId();
$entries[] = $entry2Id = $entry2->getId();
+ $crawler = $client->request('GET', '/all/list');
+ $token = $crawler->filter('#form_mass_action input[name=token]')->attr('value');
+
// Mass actions : archive
$client->request('POST', '/mass', [
+ 'token' => $token,
'toggle-archive' => '',
'entry-checkbox' => $entries,
]);
@@ -1786,8 +1790,12 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertSame(1, $res->isArchived());
+ $crawler = $client->request('GET', '/all/list');
+ $token = $crawler->filter('#form_mass_action input[name=token]')->attr('value');
+
// Mass actions : star
$client->request('POST', '/mass', [
+ 'token' => $token,
'toggle-star' => '',
'entry-checkbox' => $entries,
]);
@@ -1808,8 +1816,12 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertSame(1, $res->isStarred());
+ $crawler = $client->request('GET', '/all/list');
+ $token = $crawler->filter('#form_mass_action input[name=token]')->attr('value');
+
// Mass actions : tag
$client->request('POST', '/mass', [
+ 'token' => $token,
'tag' => '',
'tags' => 'foo',
'entry-checkbox' => $entries,
@@ -1838,8 +1850,12 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertNotContains('foo', $res->getTagsLabel());
+ $crawler = $client->request('GET', '/all/list');
+ $token = $crawler->filter('#form_mass_action input[name=token]')->attr('value');
+
// Mass actions : delete
$client->request('POST', '/mass', [
+ 'token' => $token,
'delete' => '',
'entry-checkbox' => $entries,
]);