Bug #17899
closedMisconfigured search/replace-patterns in t3lib_parsehtml->mapTags
0%
Description
I think there are misconfigured search-/replace-patterns used within t3lib_parsehtml->mapTags l.970:
$value = preg_replace('/'.preg_quote($ltChar).'(\/)?'.$from.'\s([^\>])*(\/)?\>/', $ltChar2.'$1'.$to.' $2$3>', $value);
Example:
$from = 'span';
$to = 'b';
$ltChar = '<'; //default
$ltChar2 = '<'; //default
$value = '<span style="color:red">something</span>';
Result of $value: '<b ">something</span>'
Does not make sense to me, searchpattern should be like:
'/'.preg_quote($ltChar).'(\/)?'.$from.'(\s[^\>]*)?(\/)?\>/'
replacement without whitespace before $2:
$ltChar2.'$1'.$to.'$2$3>'
results then in: '<b style="color:red">something</b>'
as expected.
Finally it does not make sense to preserve the attributes, so offer to overtake them or not by a preserving flag, summary:
function mapTags($value,$tags=array(),$ltChar='<',$ltChar2='<',$preserveAttribs=false) {
foreach($tags as $from => $to) {
$value = preg_replace('/'.preg_quote($ltChar).'(\/)?'.$from.'(\s[^\>]*)?(\/)?\>/', $ltChar2.'$1'.$to.($preserveAttribs?'$2$3>':'$3>'), $value);
}
return $value;
}
Patch attached (created against 4.1.3 core, but it's identical to 4.2alpha2)
(issue imported from #M6914)
Files
Updated by Thomas Oppelt almost 17 years ago
Little correction "Finally it MAYBE does not make sense to preserve the attributes...".
(and of course the patch results in '<b style="color:red">something' with a closing tag behind something, don't know why, but when i post this here, the closing tag disappears... ?! magic
Updated by Thomas Oppelt almost 17 years ago
overtake = take sth. over ;-) sorry
Updated by Thomas Oppelt almost 17 years ago
Ignore patch.diff, i had to correct my pattern a bit, use patch_02.diff.
Changed pattern to:
'/'.preg_quote($ltChar).'(\/)?'.$from.'(\s[^\>\/]*)?(\/)?\>/'
Updated by Alexander Opitz over 11 years ago
- Status changed from New to Needs Feedback
- Target version deleted (
0)
The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?
Updated by Alexander Opitz about 11 years ago
- Status changed from Needs Feedback to Closed
- Is Regression set to No
No feedback for over 90 days.