#6415: preg_replace error on PHP 5.2 sometimes resulting in empty pages
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 3 Dec 2008 07:44:05 +0000 (07:44 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 3 Dec 2008 07:44:05 +0000 (07:44 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-2@4532 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_fe.php

index 0f283a9..453c8a5 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+
+2008-12-03  Martin Kutschker  <masi@typo3.org>
+
+       * Fixed bug #6415: preg_replace error on PHP 5.2 sometimes resulting in empty pages (thanks to Francois Suter)
+
 2008-12-02  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Updated htmlArea RTE version to 1.7.8 for TYPO3 4.2.4
index a46c0a5..4280fc0 100755 (executable)
@@ -4118,7 +4118,13 @@ if (version == "n3") {
         */
        function prefixLocalAnchorsWithScript() {
                $scriptPath = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
-               $this->content = preg_replace('/(<(a|area).*?href=")(#[^"]*")/i','${1}' . htmlspecialchars($scriptPath) . '${3}',$this->content);
+               $originalContent = $this->content;
+               $this->content = preg_replace('/(<(?:a|area).*?href=")(#[^"]*")/i', '${1}' . htmlspecialchars($scriptPath) . '${2}', $originalContent);         
+                       // There was an error in the call to preg_replace, so keep the original content (behavior prior to PHP 5.2)
+               if (function_exists('preg_last_error') && preg_last_error() > 0) {
+                       t3lib_div::sysLog('preg_replace returned error-code: ' . preg_last_error().' in function prefixLocalAnchorsWithScript. Replacement not done!' , 'cms', 4);
+                       $this->content = $originalContent;      
+               }
        }
 
        /**