Bug #69263

format.crop ViewHelper breaks inside some tags

Added by Ludwig Rafelsberger about 4 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Must have
Category:
Fluid
Target version:
Start date:
2015-08-22
Due date:
% Done:

100%

Estimated time:
0.50 h
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

The Regex used inside \TYPO3\CMS\Frontent\ContentObject\ContentObjectRenderer->cropHTML() uses a list of known html tags to do its work. Said list misses a lot of html5 tags. Furthermore, it does not respect <script> tags (as a @todo comment says).

How to reproduce: (constructing a bad outcome of this bug)

Steps

  • Use a Fluid template containing this:
    {someRteContent -> f:format.html() -> f:format.crop(maxCharacters: 25)}
  • allow iframe tags in the RTE configuration
    (I know, I know, bad…. But: even default, "good" tags like article are broken)
  • have an Editor place an iframe tag at the affected crop position
    Lets assume, the editor embeds a YouTube video there:
      <h1>Big buck bunny</h1>
      <iframe width="560" height="315" src="https://www.youtube.com/embed/YE7VzlLtp-4" frameborder="0" allowfullscreen></iframe>
      <p>Lorem ipsum dolor foo bar</p>

Expected result

  <h1>Big buck bunny</h1>
  <iframe width="560" height="315" src="https://www.youtube.com/embed/YE7VzlLtp-4" frameborder="0" allowfullscreen></iframe>
  <p>Lorem ipsum...</p>

Actual result

  <h1>Big buck bunny</h1>
  <iframe w...

This is obviously invalid html, effectively "hiding" any later output (using typical rendering engines).

Associated revisions

Revision 370e9937 (diff)
Added by Ludwig Rafelsberger about 4 years ago

[BUGFIX] Do not crop inside known html tags

This change adds missing tags to the regex used to match html tags.
Furthermore, scripting tags are added, so that they will not be counted
nor split apart.

This list of html tags was extracted from the current W3C html5
standard recommendation at [1] and merged with tags from the current
code that are not (or no longer) in the W3C standard recommendation
(e.g: TYPO3's internal <link> tag).

---
[1]: http://www.w3.org/TR/html5/semantics.html#semantics

Resolves: #69263
Releases: master, 6.2
Change-Id: Id58dcf3470ed06256b9b8f744dd13891757faef1
Reviewed-on: http://review.typo3.org/42841
Reviewed-by: Jigal van Hemert <>
Tested-by: Jigal van Hemert <>
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

Revision aac1705f (diff)
Added by Benni Mack about 4 years ago

[BUGFIX] Do not crop inside known html tags

This change adds missing tags to the regex used to match html tags.
Furthermore, scripting tags are added, so that they will not be counted
nor split apart.

This list of html tags was extracted from the current W3C html5
standard recommendation at [1] and merged with tags from the current
code that are not (or no longer) in the W3C standard recommendation
(e.g: TYPO3's internal <link> tag).

---
[1]: http://www.w3.org/TR/html5/semantics.html#semantics

Resolves: #69263
Releases: master, 6.2
Change-Id: Id58dcf3470ed06256b9b8f744dd13891757faef1
Reviewed-on: http://review.typo3.org/43995
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

Revision c378495e (diff)
Added by Benni Mack about 4 years ago

[FOLLOWUP][BUGFIX] Do not crop inside known html tags

Fixed indent spaces to tabs.

This change adds missing tags to the regex used to match html tags.
Furthermore, scripting tags are added, so that they will not be counted
nor split apart.

This list of html tags was extracted from the current W3C html5
standard recommendation at [1] and merged with tags from the current
code that are not (or no longer) in the W3C standard recommendation
(e.g: TYPO3's internal <link> tag).

---
[1]: http://www.w3.org/TR/html5/semantics.html#semantics

Change-Id: Ie1aedecbfd46c82b49f34936a96004af29c63d54
Resolves: #69263
Releases: 6.2
Reviewed-on: http://review.typo3.org/43996
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

History

#1 Updated by Gerrit Code Review about 4 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 http://review.typo3.org/42841

#2 Updated by Benni Mack about 4 years ago

  • Category changed from Frontend to Fluid

#3 Updated by Benni Mack about 4 years ago

  • Target version changed from 7.5 to 7 LTS

#4 Updated by Gerrit Code Review about 4 years ago

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

#5 Updated by Gerrit Code Review about 4 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43995

#6 Updated by Ludwig Rafelsberger about 4 years ago

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

#7 Updated by Gerrit Code Review about 4 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43996

#8 Updated by Benni Mack about 4 years ago

  • Status changed from Under Review to Resolved

#9 Updated by Riccardo De Contardi almost 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF