mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
Merge pull request #2328 from wallabag/avoid-duplicate-url
Avoid duplicate url with accents
This commit is contained in:
commit
92395680b6
2 changed files with 45 additions and 1 deletions
|
@ -281,7 +281,7 @@ class EntryRepository extends EntityRepository
|
|||
public function findByUrlAndUserId($url, $userId)
|
||||
{
|
||||
$res = $this->createQueryBuilder('e')
|
||||
->where('e.url = :url')->setParameter('url', $url)
|
||||
->where('e.url = :url')->setParameter('url', urldecode($url))
|
||||
->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
|
|
@ -160,6 +160,50 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$this->assertContains('/view/', $client->getResponse()->getTargetUrl());
|
||||
}
|
||||
|
||||
public function testPostNewOkUrlExistWithAccent()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$url = 'http://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing';
|
||||
|
||||
$crawler = $client->request('GET', '/new');
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$form = $crawler->filter('form[name=entry]')->form();
|
||||
|
||||
$data = [
|
||||
'entry[url]' => $url,
|
||||
];
|
||||
|
||||
$client->submit($form, $data);
|
||||
|
||||
$crawler = $client->request('GET', '/new');
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$form = $crawler->filter('form[name=entry]')->form();
|
||||
|
||||
$data = [
|
||||
'entry[url]' => $url,
|
||||
];
|
||||
|
||||
$client->submit($form, $data);
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertContains('/view/', $client->getResponse()->getTargetUrl());
|
||||
|
||||
$em = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
$entry = $em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByUrl(urldecode($url));
|
||||
|
||||
$em->remove($entry);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will require an internet connection.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue