diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-01 17:57:38 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-01 18:00:11 +0200 |
commit | 19ca0b2f355a657dd296bfa782473ffd45280572 (patch) | |
tree | 2e820ab1efa3ad414fcf45a88afaf2933824eecc | |
parent | c4bf7af96f52aaafd13049e74f27b368eec79bf8 (diff) | |
download | wallabag-19ca0b2f355a657dd296bfa782473ffd45280572.tar.gz wallabag-19ca0b2f355a657dd296bfa782473ffd45280572.tar.zst wallabag-19ca0b2f355a657dd296bfa782473ffd45280572.zip |
Avoid duplicate url with accents
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 2 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 302e5a53..1b023e96 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -281,7 +281,7 @@ class EntryRepository extends EntityRepository | |||
281 | public function findByUrlAndUserId($url, $userId) | 281 | public function findByUrlAndUserId($url, $userId) |
282 | { | 282 | { |
283 | $res = $this->createQueryBuilder('e') | 283 | $res = $this->createQueryBuilder('e') |
284 | ->where('e.url = :url')->setParameter('url', $url) | 284 | ->where('e.url = :url')->setParameter('url', urldecode($url)) |
285 | ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) | 285 | ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) |
286 | ->getQuery() | 286 | ->getQuery() |
287 | ->getResult(); | 287 | ->getResult(); |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index a74c17d9..ebcf3f5a 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -160,6 +160,41 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
160 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); | 160 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); |
161 | } | 161 | } |
162 | 162 | ||
163 | public function testPostNewOkUrlExistWithAccent() | ||
164 | { | ||
165 | $this->logInAs('admin'); | ||
166 | $client = $this->getClient(); | ||
167 | |||
168 | $url = 'http://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing'; | ||
169 | |||
170 | $crawler = $client->request('GET', '/new'); | ||
171 | |||
172 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
173 | |||
174 | $form = $crawler->filter('form[name=entry]')->form(); | ||
175 | |||
176 | $data = [ | ||
177 | 'entry[url]' => $url, | ||
178 | ]; | ||
179 | |||
180 | $client->submit($form, $data); | ||
181 | |||
182 | $crawler = $client->request('GET', '/new'); | ||
183 | |||
184 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
185 | |||
186 | $form = $crawler->filter('form[name=entry]')->form(); | ||
187 | |||
188 | $data = [ | ||
189 | 'entry[url]' => $url, | ||
190 | ]; | ||
191 | |||
192 | $client->submit($form, $data); | ||
193 | |||
194 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
195 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); | ||
196 | } | ||
197 | |||
163 | /** | 198 | /** |
164 | * This test will require an internet connection. | 199 | * This test will require an internet connection. |
165 | */ | 200 | */ |