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

ChangeLog
t3lib/class.t3lib_parsehtml.php

index 96eb511..303ecd0 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-07  Steffen Gebert  <steffen@steffen-gebert.de>
 
        * Added feature #16493: Editable FlexForms require a possibility to update group access lists within update wizard (Thanks to Kai Vogel)
index 0093e91..33c8183 100644 (file)
@@ -88,6 +88,8 @@
 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
@@ -741,9 +743,12 @@ class t3lib_parsehtml {
                                        $tagContent = substr($tok, $endTag, $tagEnd - $endTag);
                                        $tagParts = preg_split('/\s+/s', $tagContent, 2);
                                        $tagName = strtolower($tagParts[0]);
+                                       $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'], '')) {
@@ -926,7 +931,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 {