[BUGFIX] Incorrect RTE transform of external URL with @ character 00/17100/2
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 10 Dec 2012 23:19:54 +0000 (18:19 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 11 Dec 2012 14:52:23 +0000 (15:52 +0100)
Problem: External url with @ character is transformed in mail href
on way to the RTE
Solution: Check for presence of scheme as is done by
tslib_cObj->typolink.
Add unit tests cases.

Change-Id: Ibdf7f2bc22580c01d6bab3f7d888d0c7a2ea5874
Resolves: #32605
Releases: 6.0, 6.1
Reviewed-on: https://review.typo3.org/17100
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Tests/Unit/Html/RteHtmlParserTest.php

index 04ca775..d0fdb1e 100644 (file)
@@ -740,7 +740,9 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
                                $link_param = $tagCode[1];
                                $href = '';
                                // Parsing the typolink data. This parsing is roughly done like in tslib_content->typolink()
                                $link_param = $tagCode[1];
                                $href = '';
                                // Parsing the typolink data. This parsing is roughly done like in tslib_content->typolink()
-                               if (strstr($link_param, '@')) {
+                               // Parse URL:
+                               $pU = parse_url($link_param);
+                               if (strstr($link_param, '@') && (!$pU['scheme'] || $pU['scheme'] == 'mailto')) {
                                        // mailadr
                                        $href = 'mailto:' . preg_replace('/^mailto:/i', '', $link_param);
                                } elseif (substr($link_param, 0, 1) == '#') {
                                        // mailadr
                                        $href = 'mailto:' . preg_replace('/^mailto:/i', '', $link_param);
                                } elseif (substr($link_param, 0, 1) == '#') {
@@ -754,8 +756,6 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
                                        } else {
                                                $fileChar = intval(strpos($link_param, '/'));
                                                $urlChar = intval(strpos($link_param, '.'));
                                        } else {
                                                $fileChar = intval(strpos($link_param, '/'));
                                                $urlChar = intval(strpos($link_param, '.'));
-                                               // Parse URL:
-                                               $pU = parse_url($link_param);
                                                // Detects if a file is found in site-root.
                                                list($rootFileDat) = explode('?', $link_param);
                                                $rFD_fI = pathinfo($rootFileDat);
                                                // Detects if a file is found in site-root.
                                                list($rootFileDat) = explode('?', $link_param);
                                                $rFD_fI = pathinfo($rootFileDat);
index f265158..b6ddc8f 100644 (file)
@@ -41,7 +41,8 @@ class RteHtmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->fixture->procOptions = array(
                        'dontConvBRtoParagraph' => '1',
                        'preserveDIVSections' => '1',
                $this->fixture->procOptions = array(
                        'dontConvBRtoParagraph' => '1',
                        'preserveDIVSections' => '1',
-                       'allowTagsOutside' => 'hr, address'
+                       'allowTagsOutside' => 'hr, address',
+                       'overruleMode' => 'ts_css'
                );
        }
 
                );
        }
 
@@ -122,6 +123,29 @@ class RteHtmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertEquals($expectedResult, $this->fixture->TS_transform_db($content, TRUE));
        }
 
                $this->assertEquals($expectedResult, $this->fixture->TS_transform_db($content, TRUE));
        }
 
-}
+       /**
+        * Data provider for linkWithAtSignCorrectlyTransformedOnWayToRTE
+        */
+       public static function linkWithAtSignCorrectlyTransformedOnWayToRTEProvider() {
+               return array(
+                       'external url with @ sign' => array(
+                               '<link http://www.example.org/at@sign>link text</link>',
+                               '<p><a href="http://www.example.org/at@sign" data-htmlarea-external="1">link text</a></p>'
+                       ),
+                       'email address with @ sign' => array(
+                               '<link name@example.org - mail "Opens window for sending email">link text</link>',
+                               '<p><a href="mailto:name@example.org" class="mail" title="Opens window for sending email">link text</a></p>'
+                       )
+               );
+       }
 
 
+       /**
+        * @test
+        * @dataProvider linkWithAtSignCorrectlyTransformedOnWayToRTEProvider
+        */
+       public function linkWithAtSignCorrectlyTransformedOnWayToRTE($content, $expectedResult) {
+               $thisConfig = array('proc.' => $this->fixture->procOptions);
+               $this->assertEquals($expectedResult, $this->fixture->RTE_transform($content, array(), 'rte', $thisConfig));
+       }
+}
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file