From 31c04668156638017a1c211100d7b86e5faff4d4 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 24 Dec 2018 02:27:45 +0100 Subject: [PATCH 1/5] [ticket/15921] Updated dependencies to latest textformatter PHPBB3-15921 --- phpBB/composer.json | 2 +- phpBB/composer.lock | 27 +++++++++---------- phpBB/phpbb/textformatter/s9e/link_helper.php | 25 +++++++---------- .../s9e/default_formatting_test.php | 2 +- .../tickets_data/PHPBB3-15348.html | 2 +- 5 files changed, 26 insertions(+), 32 deletions(-) diff --git a/phpBB/composer.json b/phpBB/composer.json index 4f796a9dcb..d192fd57c8 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -33,7 +33,7 @@ "marc1706/fast-image-size": "^1.1", "paragonie/random_compat": "^1.4", "patchwork/utf8": "^1.1", - "s9e/text-formatter": "~0.13.0", + "s9e/text-formatter": "^1.3", "symfony/config": "^2.8", "symfony/console": "^2.8", "symfony/debug": "^2.8", diff --git a/phpBB/composer.lock b/phpBB/composer.lock index d235568697..ff5e10f271 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c843abc1344cd9df37f63c08a125cad0", + "content-hash": "6daa2f5f7a161377dee1835bd4d5b463", "packages": [ { "name": "bantu/ini-get-wrapper", @@ -342,7 +342,7 @@ "oauth", "security" ], - "time": "2016-07-12T22:15:00+00:00" + "time": "2018-02-14T22:37:14+00:00" }, { "name": "marc1706/fast-image-size", @@ -505,7 +505,7 @@ "pseudorandom", "random" ], - "time": "2017-03-13T16:22:52+00:00" + "time": "2018-04-04T21:48:54+00:00" }, { "name": "patchwork/utf8", @@ -661,16 +661,16 @@ }, { "name": "s9e/text-formatter", - "version": "0.13.1", + "version": "1.3.2", "source": { "type": "git", "url": "https://github.com/s9e/TextFormatter.git", - "reference": "804ed8fdfa9fd0c8d99f5a33000d4f7e5ed90c6f" + "reference": "640b65b0d4c1de93bc98000c003998c08b2e7256" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/804ed8fdfa9fd0c8d99f5a33000d4f7e5ed90c6f", - "reference": "804ed8fdfa9fd0c8d99f5a33000d4f7e5ed90c6f", + "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/640b65b0d4c1de93bc98000c003998c08b2e7256", + "reference": "640b65b0d4c1de93bc98000c003998c08b2e7256", "shasum": "" }, "require": { @@ -681,8 +681,8 @@ }, "require-dev": { "matthiasmullie/minify": "*", - "php": ">=5.4.7", - "s9e/regexp-builder": ">=1.3.0" + "php-coveralls/php-coveralls": "*", + "s9e/regexp-builder": "1.*" }, "suggest": { "ext-curl": "Improves the performance of the MediaEmbed plugin and some JavaScript minifiers", @@ -722,7 +722,7 @@ "parser", "shortcodes" ], - "time": "2017-12-10T00:55:53+00:00" + "time": "2018-12-23T20:27:39+00:00" }, { "name": "symfony/config", @@ -2293,7 +2293,8 @@ "authors": [ { "name": "Michiel Rook", - "email": "mrook@php.net" + "email": "mrook@php.net", + "role": "Lead" }, { "name": "Phing Community", @@ -2891,9 +2892,7 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" + "email": "fabien@symfony.com" } ], "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", diff --git a/phpBB/phpbb/textformatter/s9e/link_helper.php b/phpBB/phpbb/textformatter/s9e/link_helper.php index 0f44603dec..1e113b6449 100644 --- a/phpBB/phpbb/textformatter/s9e/link_helper.php +++ b/phpBB/phpbb/textformatter/s9e/link_helper.php @@ -23,14 +23,16 @@ class link_helper * * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag * @param \s9e\TextFormatter\Parser $parser Parser - * @return bool Whether the tag is valid + * @return void */ public function cleanup_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) { // Invalidate if the content of the tag matches the text attribute $text = substr($parser->getText(), $tag->getPos(), $tag->getLen()); - - return ($text !== $tag->getAttribute('text')); + if ($text === $tag->getAttribute('text')) + { + $tag->invalidate(); + } } /** @@ -40,7 +42,7 @@ class link_helper * * @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag) * @param \s9e\TextFormatter\Parser $parser Parser - * @return bool Always true to indicate that the tag is valid + * @return void */ public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) { @@ -49,7 +51,7 @@ class link_helper // the [url] BBCode when its content is used for the URL if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText())) { - return true; + return; } // Capture the text between the start tag and its end tag @@ -60,8 +62,6 @@ class link_helper // Create a tag that consumes the link's text $parser->addSelfClosingTag('LINK_TEXT', $start, $length)->setAttribute('text', $text); - - return true; } /** @@ -84,7 +84,7 @@ class link_helper * * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag * @param string $board_url Forum's root URL (with trailing slash) - * @return bool Always true to indicate that the tag is valid + * @return void */ public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url) { @@ -93,15 +93,13 @@ class link_helper { $tag->setAttribute('text', substr($text, strlen($board_url))); } - - return true; } /** * Truncate the replacement text set in a LINK_TEXT tag * * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @return bool Always true to indicate that the tag is valid + * @return void */ public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag) { @@ -109,10 +107,7 @@ class link_helper if (utf8_strlen($text) > 55) { $text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10); + $tag->setAttribute('text', $text); } - - $tag->setAttribute('text', $text); - - return true; } } diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 8887b9daee..abaf55f374 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html index 5d44c07899..3ebe9aac88 100644 --- a/tests/text_processing/tickets_data/PHPBB3-15348.html +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -1 +1 @@ -:o k: :ok: \ No newline at end of file +:o k: :ok: \ No newline at end of file From ce90a215ba23ca33f210e369b0fba7a2a49b3a85 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Dec 2018 23:09:05 +0100 Subject: [PATCH 2/5] [ticket/15921] Update inconsistencies in composer.lock PHPBB3-15921 --- phpBB/composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/composer.lock b/phpBB/composer.lock index ff5e10f271..a80bac724e 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -342,7 +342,7 @@ "oauth", "security" ], - "time": "2018-02-14T22:37:14+00:00" + "time": "2016-07-12T22:15:00+00:00" }, { "name": "marc1706/fast-image-size", @@ -505,7 +505,7 @@ "pseudorandom", "random" ], - "time": "2018-04-04T21:48:54+00:00" + "time": "2017-03-13T16:22:52+00:00" }, { "name": "patchwork/utf8", @@ -2293,8 +2293,7 @@ "authors": [ { "name": "Michiel Rook", - "email": "mrook@php.net", - "role": "Lead" + "email": "mrook@php.net" }, { "name": "Phing Community", @@ -2479,6 +2478,7 @@ "testing", "xunit" ], + "abandoned": true, "time": "2015-03-29T14:23:04+00:00" }, { From 4bf485395e2f66bc1aa8bfc9fde458c450238cb9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Dec 2018 23:41:27 +0100 Subject: [PATCH 3/5] [ticket/15921] Use twemoji PHPBB3-15921 --- phpBB/docs/CREDITS.txt | 3 +++ phpBB/phpbb/textformatter/s9e/factory.php | 1 + 2 files changed, 4 insertions(+) diff --git a/phpBB/docs/CREDITS.txt b/phpBB/docs/CREDITS.txt index fc089f9e02..90e9a31127 100644 --- a/phpBB/docs/CREDITS.txt +++ b/phpBB/docs/CREDITS.txt @@ -104,3 +104,6 @@ Text_Diff-0.2.1 http://pear.php.net/package/Text_Diff MIT licenced: Symfony2 (c) 2004-2011 Fabien Potencier, https://symfony.com/ Cookie Consent (c) 2015 Silktide Ltd, https://cookieconsent.insites.com + +Emoji by: +Twemoji (c) 2018 Twitter, Inc, https://twemoji.twitter.com/ diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index c0bbc7b0e8..d491a7180b 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -354,6 +354,7 @@ class factory implements \phpbb\textformatter\cache_interface // Load the Emoji plugin and modify its tag's template to obey viewsmilies $tag = $configurator->Emoji->getTag(); + $tag->template = '{.}'; $tag->template = '' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . ''; /** From c51859c0bdaf1997efb6a8d792628bd35165bfec Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 27 Dec 2018 10:36:41 +0100 Subject: [PATCH 4/5] [ticket/15921] Update tests for twemoji PHPBB3-15921 --- tests/text_formatter/s9e/default_formatting_test.php | 2 +- tests/text_processing/tickets_data/PHPBB3-15348.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index abaf55f374..05a41c5095 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: ' . ' + 'Emoji: ' . ' ), array( "Emoji: \xF0\x9F\x98\x80", diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html index 3ebe9aac88..1794232d08 100644 --- a/tests/text_processing/tickets_data/PHPBB3-15348.html +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -1 +1 @@ -:o k: :ok: \ No newline at end of file +:o k: :ok: \ No newline at end of file From e9310c928e8531a560d3034dba2db1a0d2f9a395 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 29 Dec 2018 11:12:04 +0100 Subject: [PATCH 5/5] [ticket/15921] Use backward compatible template for emojis PHPBB3-15921 --- phpBB/phpbb/textformatter/s9e/factory.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index d491a7180b..6191b9a315 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -354,7 +354,14 @@ class factory implements \phpbb\textformatter\cache_interface // Load the Emoji plugin and modify its tag's template to obey viewsmilies $tag = $configurator->Emoji->getTag(); - $tag->template = '{.}'; + $tag->template = ' + + {.} + + + {.} + + '; $tag->template = '' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . ''; /**