?
avatar wronax
wronax
13 Jul 2016

Steps to reproduce the issue

This issue can be reproduce on windows servers with backslash as a folder separator.

You can see this in DJ-MegaMenu module where folderlist field is used for selecting theme

<field name="theme" type="folderlist" default="default" label="MOD_DJMEGAMENU_THEME" description="MOD_DJMEGAMENU_THEME_DESC" directory="modules/mod_djmegamenu/themes" hide_none="true" hide_default="true">
    <option value="_override">MOD_DJMEGAMENU_THEME_OVERRIDE</option>
    <option value="_custom">MOD_DJMEGAMENU_CUSTOM_THEME</option>
</field>

Expected result

- override -
- custom -
classic
default

Actual result

- override -
- custom -
C:\xampp\htdocs\joomla3\modules\mod_djmegamenu\themes/classic
C:\xampp\htdocs\joomla3\modules\mod_djmegamenu\themes/default

System information (as much as possible)

PHP 5.4.4

Additional comments

This can be fixed by replacing the 189 line in libraries/joomla/form/fields/folderlist.php file

$path = JPATH_ROOT . '/' . $path;

with

$path = JPath::clean(JPATH_ROOT . '/' . $path);
avatar wronax wronax - open - 13 Jul 2016
avatar faugro
faugro - comment - 14 Jul 2016
$path = JPath::clean(JPATH_ROOT . '/' . $path);

not solved the problem.
In my case the slash start change to backslash after line 204

$folders = JFolder::folders($path, $this->filter, $this->recursive, true);

so, for a while i add code to replace backslash to forwardslash on line 221, so it will be

$folder = str_replace('\\', '/', $folder);
$folder = trim(str_replace($path, '', $folder), '/');

I'm working on wamp in windows 7, have not test it on another environment yet.

avatar bertmert
bertmert - comment - 14 Jul 2016

You also can use JPath::clean but with an additional parameter '/'. Otherwise DIRECTRORY_SEPARATOR is used in clean(...).

$folder = JPath::clean(JPATH_ROOT . '/' . $folder , '/');
$folder = ...
avatar wronax
wronax - comment - 18 Jul 2016

@faugro
JPath::clean returns the server path to the folder, so it can contain backslashes or slashes depends on server UX.

The same $path is used as a starting point to find folders, then the $path is removed from folder paths, so how can you get backslashes in the returned folder list while JFolder::_items function use clean text slash and not DIRECTORY_SEPARATON ?

Is there anyone who can check this and create a pull request?

avatar cheesegrits
cheesegrits - comment - 24 Jul 2016

I've submitted a PR:

#11288

Anyone interested in getting this merged should test it, and report test results on the PR.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11102.

avatar brianteeman
brianteeman - comment - 25 Jul 2016

Closed as we have a PR for testing - thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11102.

avatar brianteeman brianteeman - change - 25 Jul 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-07-25 08:29:21
Closed_By brianteeman

Add a Comment

Login with GitHub to post a comment