#39261parseFunc does not handle nested tags correct
Description
The _parseFunc function is not able to detect nested tags properly. The function is searching for the first closing tag, regardless other opening tags of the same type.
Test Code:
page.10 = TEXT
page.10.value (
<ul>
<li>first</li>
<li>second
<ul>
<li>first sub</li>
<li>second sub</li>
</ul>
</li>
</ul>
)
page.10.parseFunc {
tags.li = TEXT
tags.li.wrap = <li>LI:|</li>
tags.li.current = 1
}
Expected:
<ul>
<li>LI:first</li>
<li>LI:second
<ul>
<li>LI:first sub</li>
<li>LI:second sub</li>
</ul>
</li>
</ul>
Actual result:
<ul>
<li>LI:first</li>
<li>LI:second
<ul>
<li>first sub</li>
<li>LI:second sub</li>
</ul>
</li>
</ul>
The relevant code in class.tslib_content.php -> _parseFunc($theValue, $conf):
// If we're inside a currentTag, just take it to the end of that tag! $tempContent = strtolower(substr($theValue, $pointer)); $len = strpos($tempContent, '</' . $currentTag[0]);While parsing the content of “
- first sub is handled as one tag. On the end everything is concatinated in the correct order, so as long as you do not want to alter such an tag, you will not notice.
With this TypoScript, you get broken markup:
page.10.parseFunc {
tags.li = TEXT
tags.li.value = <li>Static</li>
}
Result is:
<ul>
<li>Static</li>
<li>Static</li>
<li>Static</li>
</ul>
</li>
</ul>Reviews 2
Related issues 5
- Bug #65234Unwanted p tag between UL and LI
- Bug #91172html comments in fluid template lead to exception
- Bug #91194Faulty follow-up tag detection in parseFunc & Co. (regression)
- Bug #92194ContentObjectRenderer wraps <img> tags in <p> tags
- Bug #93012Email address are not wrapped in A tag if config.spamProtectEmailAddresses is set