From feb239ea1006685ab3862c988309a1a5a9659559 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 11 May 2019 20:07:38 +0200 Subject: mysql: change collation of tag table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit utf8mb4_unicode_ci considers that 'caché' is equal to 'cache' which can lead to attaching incorrect tags to entries. This issue is due to some unicode normalization done by MySQL. utf8mb4_bin makes no unicode normalization, letting wallabag to consider 'cache' and 'caché' as two different tags. We change the collation of the whole table as Doctrine does not support setting a collation on a column for a specific platform (it tries to apply utf8mb4_bin even for pgsql and sqlite). Fixes #3302 Signed-off-by: Kevin Decherf --- .../CoreBundle/Controller/TagControllerTest.php | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index be17dcf5..47c83a7b 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php @@ -221,4 +221,50 @@ class TagControllerTest extends WallabagCoreTestCase $this->assertInstanceOf(Tag::class, $newTag, 'Tag "specific label" exists.'); $this->assertTrue($newTag->hasEntry($freshEntry), 'Tag "specific label" is assigned to the entry.'); } + + public function testAddUnicodeTagLabel() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $entry = new Entry($this->getLoggedInUser()); + $entry->setUrl('http://0.0.0.0/tag-caché'); + $this->getEntityManager()->persist($entry); + $this->getEntityManager()->flush(); + $this->getEntityManager()->clear(); + + $crawler = $client->request('GET', '/view/' . $entry->getId()); + + $form = $crawler->filter('form[name=tag]')->form(); + + $data = [ + 'tag[label]' => 'cache', + ]; + + $client->submit($form, $data); + + $crawler = $client->request('GET', '/view/' . $entry->getId()); + + $form = $crawler->filter('form[name=tag]')->form(); + + $data = [ + 'tag[label]' => 'caché', + ]; + + $client->submit($form, $data); + + $newEntry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->find($entry->getId()); + + $tags = $newEntry->getTags()->toArray(); + foreach ($tags as $key => $tag) { + $tags[$key] = $tag->getLabel(); + } + + $this->assertGreaterThanOrEqual(2, \count($tags)); + $this->assertNotFalse(array_search('cache', $tags, true), 'Tag cache is assigned to the entry'); + $this->assertNotFalse(array_search('caché', $tags, true), 'Tag caché is assigned to the entry'); + } } -- cgit v1.2.3