Project

General

Profile

Actions

Bug #39261

closed

parseFunc does not handle nested tags correct

Added by Martin Holtz almost 12 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2012-07-25
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.7
PHP Version:
Tags:
Complexity:
hard
Is Regression:
No
Sprint Focus:

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 "<li>second ...", the first closing tag which is found is the closing tag of "<li>first sub</li>". So, internal "<li>second<ul><li>first sub</li> 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>


Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Bug #65234: Unwanted p tag between UL and LIClosed2015-02-23

Actions
Related to TYPO3 Core - Bug #91172: html comments in fluid template lead to exceptionClosed2020-04-22

Actions
Related to TYPO3 Core - Bug #91194: Faulty follow-up tag detection in parseFunc & Co. (regression)Closed2020-04-25

Actions
Related to TYPO3 Core - Bug #93012: Email address are not wrapped in A tag if config.spamProtectEmailAddresses is setClosed2020-12-07

Actions
Related to TYPO3 Core - Bug #92194: ContentObjectRenderer wraps <img> tags in <p> tagsResolved2020-09-04

Actions
Actions

Also available in: Atom PDF