[BUGFIX] Render favicon tag only if file exists 82/31282/4
authorSascha Egerer <sascha.egerer@dkd.de>
Wed, 2 Jul 2014 07:07:58 +0000 (09:07 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Mon, 8 Dec 2014 09:41:03 +0000 (10:41 +0100)
The favicon defined by `page.shortcutIcon`
creates a <link rel="icon"> tag in the frontend.

This tag should only be renderd if the defined
icon exists.

Resolves: #24481
Releases: master, 6.2
Change-Id: Ia266c730c0ea517b03d6666502b68f41efaf1304
Reviewed-on: http://review.typo3.org/31282
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/frontend/Classes/Page/PageGenerator.php

index 3144867..41d070c 100644 (file)
@@ -416,15 +416,16 @@ class PageGenerator {
                }
                if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
                        $favIcon = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
-                       $iconMimeType = '';
-                       if (function_exists('finfo_open')) {
-                               if ($finfo = @finfo_open(FILEINFO_MIME)) {
-                                       $iconMimeType = ' type="' . finfo_file($finfo, (PATH_site . $favIcon)) . '"';
-                                       finfo_close($finfo);
-                                       $pageRenderer->setIconMimeType($iconMimeType);
+                       if (is_file(PATH_site . $favIcon)) {
+                               if (function_exists('finfo_open')) {
+                                       if ($finfo = @finfo_open(FILEINFO_MIME)) {
+                                               $iconMimeType = ' type="' . finfo_file($finfo, (PATH_site . $favIcon)) . '"';
+                                               finfo_close($finfo);
+                                               $pageRenderer->setIconMimeType($iconMimeType);
+                                       }
                                }
+                               $pageRenderer->setFavIcon(GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $favIcon);
                        }
-                       $pageRenderer->setFavIcon(GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $favIcon);
                }
                // Including CSS files
                if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {