Project

General

Profile

Actions

Bug #17899

closed

Misconfigured search/replace-patterns in t3lib_parsehtml->mapTags

Added by Thomas Oppelt over 16 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2007-12-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

patch.diff (531 Bytes) patch.diff Administrator Admin, 2007-12-07 23:25
patch_02.diff (787 Bytes) patch_02.diff Administrator Admin, 2007-12-08 12:08
Actions #1

Updated by Thomas Oppelt over 16 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

Actions #2

Updated by Thomas Oppelt over 16 years ago

overtake = take sth. over ;-) sorry

Actions #3

Updated by Thomas Oppelt over 16 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[^\>\/]*)?(\/)?\>/'

Actions #4

Updated by Chris topher almost 14 years ago

Same code still present in 4.4beta2.

Actions #5

Updated by Alexander Opitz almost 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)?

Actions #6

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to Closed
  • Is Regression set to No

No feedback for over 90 days.

Actions

Also available in: Atom PDF