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

Dmitry Dulepov [typo3] dmitry at typo3.org
Mon Jan 21 08:35:20 CET 2008


Hi!

Jan-Erik Revsbech wrote:
> 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'

-1. Your expression will match to the second href while original will match to the first in this string:

<a href="#x1"> href="#x2">

Result for original regexp:

<a href="http://path/#x1"> href="#x2" </a>

Result for your regexp:

<a href="#x1"> href="http://path/#x2" </a>

Question mark in the first expression is used to find shortest match.

-- 
Dmitry Dulepov
TYPO3 core team
Web: http://typo3bloke.net/
Skype: callto:liels_bugs
"Nothing is impossible. There are only limits to our knowledge"


More information about the TYPO3-team-core mailing list