From 92078dce3393ea705361e1c3c0a332db778ccb0a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 29 Apr 2015 23:22:30 +0200 Subject: [PATCH 1/5] [ticket/11742] Removed tabs-to-space conversion in [code] PHPBB3-11742 --- phpBB/phpbb/textformatter/s9e/renderer.php | 43 ------------------- phpBB/styles/prosilver/template/bbcode.html | 4 +- .../tickets_data/PHPBB3-11742.html | 1 + .../tickets_data/PHPBB3-11742.txt | 1 + 4 files changed, 4 insertions(+), 45 deletions(-) create mode 100644 tests/text_processing/tickets_data/PHPBB3-11742.html create mode 100644 tests/text_processing/tickets_data/PHPBB3-11742.txt diff --git a/phpBB/phpbb/textformatter/s9e/renderer.php b/phpBB/phpbb/textformatter/s9e/renderer.php index 8999f1d25f..51bc44f339 100644 --- a/phpBB/phpbb/textformatter/s9e/renderer.php +++ b/phpBB/phpbb/textformatter/s9e/renderer.php @@ -234,10 +234,6 @@ class renderer implements \phpbb\textformatter\renderer_interface } $html = $this->renderer->render($xml); - if (stripos($html, 'replace_tabs_in_code($html); - } /** * Modify a rendered text @@ -253,45 +249,6 @@ class renderer implements \phpbb\textformatter\renderer_interface return $html; } - /** - * Replace tabs in code elements - * - * @see bbcode::bbcode_second_pass_code() - * - * @param string $html Original HTML - * @return string Modified HTML - */ - protected function replace_tabs_in_code($html) - { - return preg_replace_callback( - '((]*>)(.*?)())is', - function ($captures) - { - $code = $captures[2]; - - $code = str_replace("\t", '   ', $code); - $code = str_replace(' ', '  ', $code); - $code = str_replace(' ', '  ', $code); - $code = str_replace("\n ", "\n ", $code); - - // keep space at the beginning - if (!empty($code) && $code[0] == ' ') - { - $code = ' ' . substr($code, 1); - } - - // remove newline at the beginning - if (!empty($code) && $code[0] == "\n") - { - $code = substr($code, 1); - } - - return $captures[1] . $code . $captures[3]; - }, - $html - ); - } - /** * {@inheritdoc} */ diff --git a/phpBB/styles/prosilver/template/bbcode.html b/phpBB/styles/prosilver/template/bbcode.html index 3e38d13a32..af8e6ae4b0 100644 --- a/phpBB/styles/prosilver/template/bbcode.html +++ b/phpBB/styles/prosilver/template/bbcode.html @@ -12,8 +12,8 @@
-

{L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

-
+

{L_CODE}{L_COLON} {L_SELECT_ALL_CODE}


+
diff --git a/tests/text_processing/tickets_data/PHPBB3-11742.html b/tests/text_processing/tickets_data/PHPBB3-11742.html new file mode 100644 index 0000000000..e7890eef19 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11742.html @@ -0,0 +1 @@ +

CODE: Select all

	tab
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-11742.txt b/tests/text_processing/tickets_data/PHPBB3-11742.txt new file mode 100644 index 0000000000..db72e5dda0 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-11742.txt @@ -0,0 +1 @@ +[code] tab[/code] \ No newline at end of file From ad84a40c002990ea723d7b756313820b06e8012a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sun, 3 May 2015 02:40:15 +0200 Subject: [PATCH 2/5] [ticket/11742] Updated default formatting tests to match the new default PHPBB3-11742 --- tests/text_formatter/s9e/default_formatting_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 79232562cf..89d2cc53e1 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -68,7 +68,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( '[code]unparsed code[/code]', - '

CODE: Select all

unparsed code
' + '

CODE: Select all

unparsed code
' ), array( '[list]no item[/list]', @@ -181,12 +181,12 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case array( // Do not parse textual bbcodes in code '[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]', - '

CODE: Select all

unparsed code [b]bold [i]bold + italic[/i][/b]
' + '

CODE: Select all

unparsed code [b]bold [i]bold + italic[/i][/b]
' ), array( // Do not parse quote bbcodes in code '[code]unparsed code [quote="username"]quoted[/quote][/code]', - '

CODE: Select all

unparsed code [quote="username"]quoted[/quote]
' + '

CODE: Select all

unparsed code [quote="username"]quoted[/quote]
' ), array( // Textual bbcode nesting into textual bbcode @@ -195,7 +195,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "[code]\tline1\n line2[/code]", - '

CODE: Select all

   line1
' . "\n" . '  line2
' + '

CODE: Select all

' . "\tline1\n  line2
" ), array( '... http://example.org ...', From adbc45b48654f4c89e87f4163481332579d81adc Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 23 May 2015 01:53:32 +0200 Subject: [PATCH 3/5] [ticket/11742] Removed whitespace collapsing in codebox [ci skip] PHPBB3-11742 --- phpBB/styles/prosilver/theme/content.css | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 380b285b83..85c3cb9f4c 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -513,7 +513,6 @@ blockquote .codebox { display: block; height: auto; max-height: 200px; - white-space: normal; padding-top: 5px; font: 0.9em Monaco, "Andale Mono","Courier New", Courier, mono; line-height: 1.3em; From ebda279bea6ea3ff5522c7af1556874909a27b18 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 23 May 2015 19:17:55 +0200 Subject: [PATCH 4/5] [ticket/11742] Updated s9e\TextFormatter PHPBB3-11742 --- phpBB/composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/composer.lock b/phpBB/composer.lock index dc7608b37e..64927a409a 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -220,12 +220,12 @@ "source": { "type": "git", "url": "https://github.com/s9e/TextFormatter.git", - "reference": "29c5959f4425934a53b6fdb42760d719b95a6e82" + "reference": "0a6016ab96ab1da5be73f7a407f96f57d307b6b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/29c5959f4425934a53b6fdb42760d719b95a6e82", - "reference": "29c5959f4425934a53b6fdb42760d719b95a6e82", + "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/0a6016ab96ab1da5be73f7a407f96f57d307b6b6", + "reference": "0a6016ab96ab1da5be73f7a407f96f57d307b6b6", "shasum": "" }, "require": { @@ -270,7 +270,7 @@ "parser", "shortcodes" ], - "time": "2015-05-18 04:48:32" + "time": "2015-05-23 17:07:15" }, { "name": "symfony/config", From 3f52429e3d1548ca1faa203047d9326b0e6d4baa Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 23 May 2015 19:18:02 +0200 Subject: [PATCH 5/5] [ticket/11742] Added test PHPBB3-11742 --- tests/text_formatter/s9e/default_formatting_test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 89d2cc53e1..2aa15146aa 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -197,6 +197,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case "[code]\tline1\n line2[/code]", '

CODE: Select all

' . "\tline1\n  line2
" ), + array( + "[code]\n\tline1\n line2[/code]", + '

CODE: Select all

' . "\tline1\n  line2
" + ), array( '... http://example.org ...', '... http://example.org ...'