Fixed bug #5003: prefixRelPath() incorrectly changes links to anchors (Thanks to...
authorBenni Mack <benni.mack@typo3.org>
Fri, 7 May 2010 16:23:33 +0000 (16:23 +0000)
committerBenni Mack <benni.mack@typo3.org>
Fri, 7 May 2010 16:23:33 +0000 (16:23 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7560 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_parsehtml.php

index 4aab55b..4cc38dd 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-05-07  Benjamin Mack  <benni@typo3.org>
+
+       * Fixed bug #5003: prefixRelPath() incorrectly changes links to anchors (Thanks to Jigal van Hemert)
+
 2010-05-07  Oliver Hader  <oliver@typo3.org>
 
        * Fixed bug #13495: Workspace tiled Preview shows same version of Page
index b646a2a..17fd2ee 100644 (file)
@@ -1046,10 +1046,15 @@ class t3lib_parsehtml   {
         * @return      string          Output path, prefixed if no scheme in input string
         * @access private
         */
-       function prefixRelPath($prefix,$srcVal,$suffix='')      {
-               $pU = parse_url($srcVal);
-               if (!$pU['scheme'] && substr($srcVal, 0, 1)!='/')       { // If not an absolute URL.
-                       $srcVal = $prefix.$srcVal.$suffix;
+       function prefixRelPath($prefix, $srcVal, $suffix = '') {
+                       // Only prefix if it's not an absolute URL or 
+                       // only a link to a section within the page.
+               if (substr($srcVal, 0, 1) != '/' && substr($srcVal, 0, 1) != '#') {
+                       $urlParts = parse_url($srcVal);
+                               // only prefix URLs without a scheme
+                       if (!$urlParts['scheme']) {
+                               $srcVal = $prefix . $srcVal . $suffix;
+                       }
                }
                return $srcVal;
        }