Fixed bug #9455: RTE incorrectly modifies external links and causes problems with...
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 10 May 2010 16:52:58 +0000 (16:52 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 10 May 2010 16:52:58 +0000 (16:52 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7575 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_parsehtml_proc.php
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php

index f77cd9c..6f54952 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-05-10  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #9455: RTE incorrectly modifies external links and causes problems with subdomains
+
 2010-05-07  Steffen Kamper  <info@sk-typo3.de>
 
        * Fixed bug #14335: Install Tool buttons have no hover state (thanks to Steffen Gebert)
index cacf9e8..1caae12 100644 (file)
@@ -643,6 +643,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                unset($attribArray_copy['target']);
                                unset($attribArray_copy['class']);
                                unset($attribArray_copy['title']);
+                               unset($attribArray_copy['external']);
                                if ($attribArray_copy['rteerror'])      {       // Unset "rteerror" and "style" attributes if "rteerror" is set!
                                        unset($attribArray_copy['style']);
                                        unset($attribArray_copy['rteerror']);
@@ -652,17 +653,22 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        $attribArray['class'] = preg_match('/ /', $attribArray['class']) ? '"' . $attribArray['class'] . '"' : $attribArray['class'];
                                        $attribArray['title'] = preg_match('/ /', $attribArray['title']) ? '"' . $attribArray['title'] . '"' : $attribArray['title'];
                                                // Creating the TYPO3 pseudo-tag "<LINK>" for the link (includes href/url, target and class attributes):
-                                       $bTag='<link '.$info['url'].($info['query']?',0,'.$info['query']:'').($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' '.$attribArray['title']:'').'>';
+                                               // If external attribute is set, keep the href unchanged
+                                       $href = $attribArray['external'] ? $attribArray['href'] : $info['url'].($info['query']?',0,'.$info['query']:'');
+                                       $bTag='<link '. $href . ($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' '.$attribArray['title']:'').'>';
                                        $eTag='</link>';
                                        $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
                                } else {        // ... otherwise store the link as a-tag.
                                                // Unsetting 'rtekeep' attribute if that had been set.
                                        unset($attribArray['rtekeep']);
-                                               // If the url is local, remove url-prefix
-                                       $siteURL = $this->siteUrl();
-                                       if ($siteURL && substr($attribArray['href'],0,strlen($siteURL))==$siteURL)      {
-                                               $attribArray['href']=$this->relBackPath.substr($attribArray['href'],strlen($siteURL));
+                                       if (!$attribArray['external']) {
+                                                       // If the url is local, remove url-prefix
+                                               $siteURL = $this->siteUrl();
+                                               if ($siteURL && substr($attribArray['href'],0,strlen($siteURL))==$siteURL)      {
+                                                       $attribArray['href']=$this->relBackPath.substr($attribArray['href'],strlen($siteURL));
+                                               }
                                        }
+                                       unset($attribArray['external']);
                                        $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
                                        $eTag='</a>';
                                        $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
@@ -700,6 +706,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                } else {
                                        $fileChar=intval(strpos($link_param, '/'));
                                        $urlChar=intval(strpos($link_param, '.'));
+                                       $external = FALSE;
 
                                                // Detects if a file is found in site-root OR is a simulateStaticDocument.
                                        list($rootFileDat) = explode('?',$link_param);
@@ -709,6 +716,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        } elseif($urlChar && (strstr($link_param,'//') || !$fileChar || $urlChar<$fileChar))    {       // url (external): If doubleSlash or if a '.' comes before a '/'.
                                                if (!preg_match('/^[a-z]*:\/\//',trim(strtolower($link_param))))        {$scheme='http://';} else {$scheme='';}
                                                $href = $scheme.$link_param;
+                                               $external = TRUE;
                                        } elseif($fileChar)     {       // file (internal)
                                                $href = $siteUrl.$link_param;
                                        } else {        // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to tables.php!!)
@@ -743,6 +751,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                                        ($tagCode[2]&&$tagCode[2]!='-' ? ' target="'.htmlspecialchars($tagCode[2]).'"' : '').
                                                        ($tagCode[3]&&$tagCode[3]!='-' ? ' class="'.htmlspecialchars($tagCode[3]).'"' : '').
                                                        ($tagCode[4] ? ' title="'.htmlspecialchars($tagCode[4]).'"' : '').
+                                                       ($external ? ' external="1"' : '').
                                                        ($error ? ' rteerror="'.htmlspecialchars($error).'" style="background-color: yellow; border:2px red solid; color: black;"' : '').       // Should be OK to add the style; the transformation back to databsae will remove it...
                                                        '>';
                                $eTag = '</a>';
@@ -1589,6 +1598,8 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        $uP = parse_url(strtolower($attribArray['href']));
                                        if (!$uP['scheme'])     {
                                                $attribArray['href'] = $this->siteUrl().substr($attribArray['href'],strlen($this->relBackPath));
+                                       } elseif ($uP['scheme'] != 'mailto') {
+                                               $attribArray['external'] = 1;
                                        }
                                } else {
                                        $attribArray['rtekeep'] = 1;
index d962ad3..4e78c30 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-10  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #9455: RTE incorrectly modifies external links and causes problems with subdomains
+
 2010-05-09  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Follow-up to feature #14014: htmlArea RTE should use version numbering method for CSS and JS files
index e92e73f..f8ade90 100644 (file)
@@ -247,6 +247,10 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                }
                        // Note: parseCurUrl will invoke the hooks
                $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
+               if (isset($this->curUrlArray['external']) && $this->curUrlInfo['act'] != 'mail') {
+                       $this->curUrlInfo['act'] = 'url';
+                       $this->curUrlInfo['info'] = $this->curUrlArray['href'];
+               }
                        // Determine nature of current url:
                $this->act = t3lib_div::_GP('act');
                if (!$this->act)        {
@@ -693,7 +697,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                        <tr>
                                                                <td>URL:</td>
                                                                <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
-                                                                       '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.lurlform.lurl.value)) { browse_links_setHref(document.lurlform.lurl.value); } else { browse_links_setHref(\'http://\'+document.lurlform.lurl.value); }; return link_current();" /></td>
+                                                                       '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.lurlform.lurl.value)) { browse_links_setHref(document.lurlform.lurl.value); } else { browse_links_setHref(\'http://\'+document.lurlform.lurl.value); }; browse_links_setAdditionalValue(\'external\', \'1\'); return link_current();" /></td>
                                                        </tr>
                                                </table>
                                        </form>';
@@ -890,7 +894,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                        <td>
                                                        </td>
                                                        <td colspan="3">
-                                                               <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="return link_current();" />
+                                                               <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="' . (($this->act == 'url') ? 'browse_links_setAdditionalValue(\'external\', \'1\'); ' : '') .'return link_current();" />
                                                        </td>
                                                </tr>';
                }