From 92078dce3393ea705361e1c3c0a332db778ccb0a Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Wed, 29 Apr 2015 23:22:30 +0200 Subject: [PATCH] [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