[TYPO3-core] RFC #6415: Bug: preg_replace error on php5.2 sometimes resulting in empty pages.

Francois Suter fsuter at cobweb.ch
Fri Oct 31 13:15:57 CET 2008


Hi,

REMINDER #1

I've reviewed this bug report again during the October Bug Day. New 
remarks have been added recently to the bugtracker entry, but they point 
to other problems. I think we should get this patch committed and the 
other problems can be solved with another patch.

Cheers

> This is an SVN patch request.
> 
> Type: Bugfix
> 
> Bugtracker references:
> http://bugs.typo3.org/view.php?id=6415
> 
> 
> Branches:
> Trunk
> 
> Problem:
> The function prefixLocalAnchorsWithScript in class.tslib_fe.php runs
> preg_replace directly on $this->content. 
> In php 5.2 all calls to preg_* functions will return an empty string (or
> false) if it encounters an error (This is new in PHP 5.2). thus is a pages
> consists of a lot of content with many anchor links, the
> pcre.backtrack_limit or pcre.recursiion_limit will be reached, and the
> result is a completely blank output in the frontend.
> 
> The error only occurs if the TypoScript option: config.prefixLocalAnchors is
> set to all.
> 
> The original trigger for this bug, was that the regular expression:
> '/(<(a|area).*?href=")(#[^"]*")/i' resulted in recursion_limit being reached
> on one of my sites. The regular expression is not correct, and should in my
> opinion be '/(<(a|area).+href=")(#[^"]*")/i'
> 
> Solution:
> 1: Change the regular expression to a non-faulty one
> 2: Introduce some error checking. Since php 5.2 a call to preg_last_error
> will give some insight into the result of the last call to preg_ functions.
> The patch here checks if there was an error, and if yes, then return the
> unsubstitued content (in order to avoid empty pages) and  write an entry to
> the syslog. 
> 
> Notes:
> The patch requires php 5.2 to run.
> 
> Regards
> Jan-Erik Revsbech
> MOC Systems



-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch


More information about the TYPO3-team-core mailing list