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