[TYPO3-core] RFC #6415: Bug: preg_replace error on php5.2 sometimes resulting in empty pages.
Martin Kutschker
Martin.Kutschker at n0spam-blackbox.net
Mon Jan 21 11:58:04 CET 2008
Jan-Erik Revsbech schrieb:
> 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.
Odd, but may perhaps happen when you encounter tags without any href. Eg <a
name="xxx"> is valid(so we ). Also (hypothetical) tags starting with are found.
Try this version (seeks only for non-> characters and require a white space
after the tag name):
'/(<(a|area)\s[^>]*?href=")(#[^"]*")/i'
If we don't need the tag name, we can speed it up, by making the brackets
around the tag non-capturing_
'/(<(?:a|area)\s[^>]*?href=")(#[^"]*")/i'
Masi
More information about the TYPO3-team-core
mailing list