From a5f1ff43b55fd7d7513e7d8fe8d4be86ff16cf70 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 12 Feb 2020 01:35:00 +0100 Subject: [PATCH] [ticket/16361] Truncate schemeless links to the forum PHPBB3-16361 --- phpBB/phpbb/textformatter/s9e/factory.php | 8 +++++++- tests/text_formatter/s9e/default_formatting_test.php | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index f82c7b0771..e97b4feb85 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -470,11 +470,17 @@ class factory implements \phpbb\textformatter\cache_interface $tag->attributes->add('text'); $tag->template = ''; + $board_url = generate_board_url() . '/'; $tag->filterChain ->add(array($this->link_helper, 'truncate_local_url')) ->resetParameters() ->addParameterByName('tag') - ->addParameterByValue(generate_board_url() . '/'); + ->addParameterByValue($board_url); + $tag->filterChain + ->add(array($this->link_helper, 'truncate_local_url')) + ->resetParameters() + ->addParameterByName('tag') + ->addParameterByValue(preg_replace('(^\\w+:)', '', $board_url)); $tag->filterChain ->add(array($this->link_helper, 'truncate_text')) ->resetParameters() diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index ce15a52adc..157af196d9 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -257,6 +257,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case '[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]', 'http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ), + array( + '[url]//localhost/phpbb/viewforum.php?f=1[/url]', + 'viewforum.php?f=1' + ), array( '[quote="[url=http://example.org]xxx[/url]"]...[/quote]', '
xxx wrote:...
'