Bug #18694
closedconfig.prefixLocalAnchors = all destroys links when $scriptPath starts with a number
0%
Description
TS Setup config.prefixLocalAnchors = all should insert the script path into all links with local anchors:
<a href="#asdf"> => <a href="[script_path]#asdf">
This is done in /typo3/sysext/cms/tslib/class.tslib_fe.php in line 3713, function prefixLocalAnchorsWithScript():
$this->content = preg_replace('/(<(a|area).+href=")(#[^"]*")/i','$1' . htmlspecialchars($scriptPath) . '$3',$this->content);
If $scriptPath starts with a number, the replacement string reads '$1[number]...', causing the first reference to be omitted completely.
Fix: Put the first reference into braces:
$this->content = preg_replace('/(<(a|area).+href=")(#[^"]*")/i','${1}' . htmlspecialchars($scriptPath) . '$3',$this->content);
See http://www.php.net/manual/en/function.preg-replace.php for details.
(issue imported from #M8240)
Updated by Daniel Hahler about 16 years ago
This is fixed in TYPO3_4-2, where both references ($1 and $3) are wrapped in curly braces.
Please close the bug.