Fixed bug #13695: Image output in frontend is not xhtml valid
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 9 Jan 2011 19:59:16 +0000 (19:59 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 9 Jan 2011 19:59:16 +0000 (19:59 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-3@10015 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_parsehtml.php

index 669bfa6..722eeb1 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-09  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #13695: Image output in frontend is not xhtml valid
+
 2011-01-05  Steffen Kamper  <steffen@typo3.org>
 
        * Fixed bug #16900: [Cache] Filebackend fails on windows
index df60877..835e3fd 100644 (file)
 class t3lib_parsehtml  {
 
        protected $caseShift_cache = array();
-
+               // Void elements that do not have closing tags, as defined by HTML5, except link element
+       const VOID_ELEMENTS = 'area|base|br|col|command|embed|hr|img|input|keygen|meta|param|source|track|wbr';
        /**
         * Returns the first subpart encapsulated in the marker, $marker
         * (possibly present in $content as a HTML comment)
@@ -762,9 +763,12 @@ class t3lib_parsehtml      {
                                        $tagContent = substr($tok,$endTag,$tagEnd-$endTag);
                                        $tagParts = preg_split('/\s+/s',$tagContent,2);
                                        $tagName = strtolower($tagParts[0]);
-                                       if (isset($tags[$tagName]))     {
-                                               if (is_array($tags[$tagName]))  {       // If there is processing to do for the tag:
-
+                                       $emptyTag = 0;
+                                       if (isset($tags[$tagName])) {
+                                               if (is_array($tags[$tagName])) { // If there is processing to do for the tag:
+                                                       if (preg_match('/^(' . self::VOID_ELEMENTS . ')$/i', $tagName)) {
+                                                               $emptyTag = 1;
+                                                       }
                                                        if (!$endTag)   {       // If NOT an endtag, do attribute processing (added dec. 2003)
                                                                        // Override attributes
                                                                if (strcmp($tags[$tagName]['overrideAttribs'],''))      {
@@ -922,7 +926,7 @@ class t3lib_parsehtml       {
 
                                                                if ($setTag)    {
                                                                                // Setting the tag
-                                                                       $newContent[$c++]=$this->processTag($lt.($endTag?'/':'').trim($tagParts[0].' '.$tagParts[1]).$gt,$addConfig,$endTag,$lt=='&lt;');
+                                                                       $newContent[$c++] = $this->processTag($lt . ($endTag ? '/' : '') . trim($tagParts[0] . ' ' . $tagParts[1]) . ($emptyTag ? ' /' : '' ) . $gt, $addConfig, $endTag, $lt == '&lt;');
                                                                }
                                                        }
                                                } else {