[BUGFIX] Add img longdescUrl only if available 72/44572/2
authorBenjamin Mack <benni@typo3.org>
Fri, 6 Nov 2015 12:09:06 +0000 (13:09 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 6 Nov 2015 13:03:19 +0000 (14:03 +0100)
According to the W3C standard (http://www.w3.org/TR/html-longdesc/#implementation),
longDesc should only be added if the attribute value is not empty.

The change adds an additional check to do so.

Resolves: #70685
Releases: master, 6.2
Change-Id: I4f61e61f04de81f881becee871edcc15d77deecd
Reviewed-on: https://review.typo3.org/44572
Reviewed-by: Daniel Gorges <daniel.gorges@b13.de>
Tested-by: Daniel Gorges <daniel.gorges@b13.de>
Reviewed-by: David Steeb <david.steeb@b13.de>
Tested-by: David Steeb <david.steeb@b13.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 6e81f96..d426428 100644 (file)
@@ -1947,6 +1947,8 @@ class ContentObjectRenderer
         } else {
             $longDescUrl = trim($conf['longdescURL']);
         }
+        $longDescUrl = strip_tags($longDescUrl);
+
         // "alt":
         $altParam = ' alt="' . htmlspecialchars($altText) . '"';
         // "title":
@@ -1958,8 +1960,8 @@ class ContentObjectRenderer
             $altParam .= ' title="' . htmlspecialchars($altText) . '"';
         }
         // "longDesc" URL
-        if ($longDesc) {
-            $altParam .= ' longdesc="' . htmlspecialchars(strip_tags($longDescUrl)) . '"';
+        if ($longDesc && !empty($longDescUrl)) {
+            $altParam .= ' longdesc="' . htmlspecialchars($longDescUrl) . '"';
         }
         return $altParam;
     }