[BUGFIX] Treat <pre> tags correctly in RTE 12/50112/3
authorMarkus Klein <markus.klein@typo3.org>
Fri, 7 Oct 2016 16:52:12 +0000 (18:52 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 7 Oct 2016 20:41:44 +0000 (22:41 +0200)
Do not throw away line breaks and multiple spaces of pre tag's content in RTE.
This finally allows to paste source code and keep its formatting.

Resolves: #78186
Releases: master, 7.6
Change-Id: I183032d53bf64c8f1e3acb8222288860f97fed33
Reviewed-on: https://review.typo3.org/50112
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Łukasz Uznański <l.uznanski@macopedia.pl>
Tested-by: Łukasz Uznański <l.uznanski@macopedia.pl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/css_styled_content/static/setup.txt
typo3/sysext/css_styled_content/static/v6.2/setup.txt
typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.parseFunc.ts
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Editor/Editor.js

index 1c759c4..74a322b 100644 (file)
@@ -938,6 +938,8 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser
                             $blockSplit[$k] = preg_replace(('/[' . LF . CR . ']+/'), ' ', $this->transformStyledATags($blockSplit[$k])) . $lastBR;
                         }
                         break;
+                    case 'pre':
+                        break;
                     default:
                         // Eliminate true linebreaks inside other headlist tags
                         $blockSplit[$k] = preg_replace(('/[' . LF . CR . ']+/'), ' ', $this->transformStyledATags($blockSplit[$k])) . $lastBR;
index e0dd2ff..7f695a1 100644 (file)
@@ -105,7 +105,7 @@ lib.parseFunc_RTE < lib.parseFunc
 lib.parseFunc_RTE {
        //  makelinks >
        # Processing <table> and <blockquote> blocks separately
-       externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul
+       externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre
        externalBlocks {
                # The blockquote content is passed into parseFunc again...
                blockquote.stripNL=1
index b6eea7f..6068d89 100644 (file)
@@ -106,7 +106,7 @@ lib.parseFunc_RTE < lib.parseFunc
 lib.parseFunc_RTE {
        //  makelinks >
        # Processing <table> and <blockquote> blocks separately
-       externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul
+       externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre
        externalBlocks {
                # The blockquote content is passed into parseFunc again...
                blockquote.stripNL=1
index 899e2fa..60413f5 100644 (file)
@@ -40,7 +40,7 @@ lib.parseFunc {
 lib.parseFunc_RTE < lib.parseFunc
 lib.parseFunc_RTE {
        # Processing <table> and <blockquote> blocks separately
-       externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul
+       externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre
        externalBlocks {
                # The blockquote content is passed into parseFunc again...
                blockquote {
index 030457f..1f760f3 100644 (file)
@@ -3958,7 +3958,7 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                 'allowTags' => 'a, abbr, acronym, address, article, aside, b, bdo, big, blockquote, br, caption, center, cite, code, col, colgroup, dd, del, dfn, dl, div, dt, em, font, footer, header, h1, h2, h3, h4, h5, h6, hr, i, img, ins, kbd, label, li, link, meta, nav, ol, p, pre, q, samp, sdfield, section, small, span, strike, strong, style, sub, sup, table, thead, tbody, tfoot, td, th, tr, title, tt, u, ul, var',
                 'constants' => '1',
                 'denyTags' => '*',
-                'externalBlocks' => 'article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul',
+                'externalBlocks' => 'article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre',
                 'externalBlocks.' => [
                     'article.' => [
                         'callRecursive' => '1',
index be68561..20a5463 100644 (file)
@@ -387,7 +387,6 @@ define(['TYPO3/CMS/Rtehtmlarea/HTMLArea/UserAgent/UserAgent',
                                // Collapse repeated spaces non-editable in wysiwyg
                                // Replace leading and trailing spaces non-editable in wysiwyg
                                return this.textArea.value.
-                                       replace(/[\x20]+/g, '\x20').
                                        replace(/^\x20/g, '&nbsp;').
                                        replace(/\x20$/g, '&nbsp;');
                        default: