From 13a756bfb7f73bdbd89e178617345afa18210b69 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 21 Jul 2016 03:37:44 +0200 Subject: [PATCH] [ticket/14700] Prevent an exception on duplicate smilies in text_formatter PHPBB3-14700 --- phpBB/phpbb/textformatter/s9e/factory.php | 2 +- tests/text_formatter/s9e/factory_test.php | 11 +++++++ .../s9e/fixtures/smilies_duplicate.xml | 33 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/text_formatter/s9e/fixtures/smilies_duplicate.xml diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index 8d1c0fabfe..916fdff909 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -309,7 +309,7 @@ class factory implements \phpbb\textformatter\cache_interface // Load smilies foreach ($this->data_access->get_smilies() as $row) { - $configurator->Emoticons->add( + $configurator->Emoticons->set( $row['code'], '{.}' ); diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index e74337decc..368b8a4f4b 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -170,6 +170,17 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case ); } + public function test_duplicate_smilies() + { + $fixture = __DIR__ . '/fixtures/smilies_duplicate.xml'; + $parser = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.parser'); + + $this->assertSame( + ':)', + $parser->parse(':)') + ); + } + /** * @testdox {INTTEXT} is supported in custom BBCodes */ diff --git a/tests/text_formatter/s9e/fixtures/smilies_duplicate.xml b/tests/text_formatter/s9e/fixtures/smilies_duplicate.xml new file mode 100644 index 0000000000..9645f3e516 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/smilies_duplicate.xml @@ -0,0 +1,33 @@ + + + + smiley_id + code + emotion + smiley_url + smiley_width + smiley_height + smiley_order + display_on_posting + + 1 + :) + :) + foo.png + 15 + 17 + 2 + 1 + + + 2 + :) + :) + bar.png + 15 + 17 + 2 + 2 + +
+