Project

General

Profile

Actions

Bug #39261

closed

parseFunc does not handle nested tags correct

Added by Martin Holtz over 11 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 #1

Updated by Mathias Schreiber over 9 years ago

  • Target version set to 7.2 (Frontend)
  • Is Regression set to No
Actions #2

Updated by Benni Mack almost 9 years ago

  • Target version changed from 7.2 (Frontend) to 7.4 (Backend)
Actions #3

Updated by Georg Ringer almost 9 years ago

btw still valid in 7.4-dev

Actions #4

Updated by Susanne Moog over 8 years ago

  • Target version changed from 7.4 (Backend) to 7.5
Actions #5

Updated by Benni Mack over 8 years ago

  • Target version deleted (7.5)

We need tests for that, so we can then easily fix it. Anyone up for the task? Just ping me.

Actions #6

Updated by Riccardo De Contardi over 6 years ago

This issue still affects 9.0.0-dev (latest master)

Actions #7

Updated by Gerrit Code Review over 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58946

Actions #8

Updated by Gerrit Code Review over 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58946

Actions #9

Updated by Gerrit Code Review over 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58946

Actions #10

Updated by Gerrit Code Review over 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/58946

Actions #11

Updated by Gerrit Code Review over 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/58946

Actions #12

Updated by Gerrit Code Review over 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/58946

Actions #13

Updated by Gerrit Code Review about 4 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/58946

Actions #14

Updated by Wolfgang Klinger about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #15

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions #16

Updated by Christian Eßl almost 4 years ago

  • Related to Bug #91172: html comments in fluid template lead to exception added
Actions #17

Updated by Oliver Hader almost 4 years ago

  • Related to Bug #91194: Faulty follow-up tag detection in parseFunc & Co. (regression) added
Actions #18

Updated by Daniel Siepmann over 2 years ago

  • Related to Bug #93012: Email address are not wrapped in A tag if config.spamProtectEmailAddresses is set added
Actions #19

Updated by Oliver Hader 10 months ago

  • Related to Bug #92194: ContentObjectRenderer wraps <img> tags in <p> tags added
Actions

Also available in: Atom PDF