?

Steps to reproduce the issue

Install JOOMLA on APACHE on a Windows Server environment. Favicons cannot be loaded due to a path issue in /libraries/joomla/document/html/html.php

Expected result

Favicon.ico should be loaded and no error message should appear in APACHE error log.

Actual result

Apache not being able to load the favicon.ico and producing a respective error message in the Apache error log:

[Tue Jul 29 09:44:51 2014] [error] client xxxThe given path was above the root path: Cannot map GET /C:/Webserver/httpdocs/xxxx/templates/jsn_metro_pro/favicon.ico HTTP/1.1 to file
[Tue Jul 29 10:54:13 2014] [error] client xxxThe given path is misformatted or contained invalid characters: Cannot map GET /administrator/C:/Webserver/httpdocs/xxx/administrator/templates/isis/favicon.ico HTTP/1.1 to file

System information (as much as possible)

Additional comments

When installing Joomla on Apache in a MS Windows environment, Favicon.ico cannot be loaded due to a bug in /libraries/joomla/document/html/html.php (code line 575 ff) when rendering the page.

    // Try to find a favicon by checking the template and root folder
    $path = $directory . '/';
    $dirs = array($path, JPATH_BASE . '/');
    foreach ($dirs as $dir)
    {
        $icon = $dir . 'favicon.ico';
        if (file_exists($icon))
        {
            $path = str_replace(JPATH_BASE . '/', '', $dir);
            $path = str_replace('\\', '/', $path);
            $this->addFavicon(JUri::base(true) . '/' . $path . 'favicon.ico');
            break;
        }
    }

Adding the '/' in these statements results in an unsuccessful STR_REPLACE command.
The codeline

$path = str_replace(JPATH_BASE . '/', '', $dir);

actually removes JPATH_BASE plus / from the $dir variable, if the former exists in the latter. However, on windows systems (at least on mine), the $dir variable contains: C:\Webserver\httpdocs\xxx\administrator\ (please note the last backslash, that will be compared to a slash in the str_replace) - so this str_replace NEVER succeeds (this is why the C:/Webserver survives the str_replace).

Using DIRECTORY_SEPARATOR here solves the issue.

avatar schultz-it-solutions schultz-it-solutions - open - 5 Sep 2014
avatar zero-24
zero-24 - comment - 5 Sep 2014

Thanks @schultz-it-solutions as you have a solution can you send your fixes as PR against the staging branche?

If you don't know how please see here: http://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

Thanks.

avatar schultz-it-solutions schultz-it-solutions - reference | - 5 Sep 14
avatar Bakual
Bakual - comment - 6 Sep 2014

I'm closing this issue as we were not able to reproduce it either with XAMPP, WAMPServer or UniformServer. The proposed fix instead actually breaks favicons.

It cna be reopened if there is additional information in how to reproduce it.

avatar Bakual Bakual - change - 6 Sep 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-09-06 10:44:43
avatar Bakual Bakual - close - 6 Sep 2014
avatar zero-24 zero-24 - close - 6 Sep 2014
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment