Page 1 of 1

Why JFolder::makeSafe removes dot ?

Posted: Sat May 23, 2009 3:59 pm
by meloman
Why JFolder::makeSafe removes dot ? It's a valid character for a folder name. At least on Linux...

My site is hosted in a folder with my domain name like /home/me/mydomain.com/joomla. If I use makeSafe to clean a path name received from my config form, it removes the dot, and the path is not valid.

Is it a bug in JFolder ? I think even on Windows it's a valid character for a folder name.

Re: Why JFolder::makeSafe removes dot ?

Posted: Sun May 24, 2009 11:46 pm
by airton
Hi,
Try changing /libraries/joomla/filesystem/folder.php lines 564 to 569 from:

Code: Select all

	function makeSafe($path)
	{
		$ds = (DS == '\\') ? '\\' . DS : DS;
		$regex = array('#[^A-Za-z0-9:\_\-' . $ds . ' ]#');
		return preg_replace($regex, '', $path);
	}

To:

Code: Select all

	function makeSafe($path)
	{
		$ds = (DS == '\\') ? '\\' . DS : DS;
		$regex = array('#[^A-Za-z0-9:\_\-\.' . $ds . ' ]#');
		return preg_replace($regex, '', $path);
	}
I created an artifact in the tracker and proposed a patch to correct this. You can check it at http://joomlacode.org/gf/project/joomla ... m_id=16506

Thanks for reporting,

Re: Why JFolder::makeSafe removes dot ?

Posted: Mon May 25, 2009 11:21 am
by meloman
Thanks, I will try that tonight !

Re: Why JFolder::makeSafe removes dot ?

Posted: Mon May 25, 2009 10:51 pm
by meloman
I confirm it's working.
But I will wait until it's fixed in the official code before using makeSafe in my extension...

Thanks for your time!

Re: Why JFolder::makeSafe removes dot ?

Posted: Thu Jun 24, 2010 3:10 am
by robert101083
I've got the exact same problem as the topic starter.

When I look at the change log of Joomla! 1.5.17 it says the following:
24-Apr-2010 Mark Dexter
# Reverted [#16506] JFolder::makeSafe removes dot
But the problem still exists in Joomla! 1.5.17 and 1.5.18

I use JFolder::makeSafe in a component i'm working on, so patching Joomla! is not an option.

If I look at the bug-tracker:
http://joomlacode.org/gf/project/joomla ... m_id=16506

It looks like there is no final decision made yet about this matter. Is that right?

Cheers,
Robert

edit: sorry for the major bumb :D

Re: Why JFolder::makeSafe removes dot ?

Posted: Fri Jun 25, 2010 3:33 am
by airton
robert101083 wrote:If I look at the bug-tracker:
http://joomlacode.org/gf/project/joomla ... m_id=16506

It looks like there is no final decision made yet about this matter. Is that right?
Yes, Robert, that's right.

The matter is under discussion in the JBS and the PLT and no agreement has been reached so far as for how exactly it should work. The proposed patch, besides not producing all the desired results, broke other things in 1.5.16 and was reverted in 1.5.17. We hope to reach an agreement about this soon.

Thanks for your patience.

Re: Why JFolder::makeSafe removes dot ?

Posted: Fri Jun 25, 2010 4:11 am
by meloman
What does it break? A dot is a valid character in a folder name and should not be removed by the makeSafe function. I don't understand why a bug as simple as that is still not resolved a year later!

Re: Why JFolder::makeSafe removes dot ?

Posted: Fri Jun 25, 2010 4:15 am
by robert101083
airton wrote:
robert101083 wrote:If I look at the bug-tracker:
http://joomlacode.org/gf/project/joomla ... m_id=16506

It looks like there is no final decision made yet about this matter. Is that right?
Yes, Robert, that's right.

The matter is under discussion in the JBS and the PLT and no agreement has been reached so far as for how exactly it should work. The proposed patch, besides not producing all the desired results, broke other things in 1.5.16 and was reverted in 1.5.17. We hope to reach an agreement about this soon.

Thanks for your patience.
Thanks Airton.

I've been looking at JPath::clean() as well. Can you maybe explain to me what the difference is between JPath:clean and JFolder::makeSafe()?

Cheers,
Robert

Re: Why JFolder::makeSafe removes dot ?

Posted: Wed Feb 23, 2011 6:00 pm
by marty79
bumping this as JFolder is still removing the dot and is breaking perfectly valid installations

Re: Why JFolder::makeSafe removes dot ?

Posted: Sun Nov 27, 2011 3:48 pm
by K_koo
Does anyone know how to fix this in Joomla 1.7? I've tried following the instructions but the code is different in 1.7.

I'm not a programmer so I have no idea what to delete/modify!

This is how it looks in 1.7
public static function makeSafe($path)
{
//$ds = (DS == '\\') ? '\\/' : DS;
$regex = array('#[^A-Za-z0-9:_\\\/-]#');
return preg_replace($regex, '', $path);
}
Basically I'm getting an error with an extension because it's removing the . from my domain and the path ends up as /mydomaincom/

Any help would be much appreciated!

Re: Why JFolder::makeSafe removes dot ?

Posted: Fri Dec 02, 2011 3:56 am
by haniar
is ther any solution yet ?
i have the same problem here on my joomla 1.7
can someone answer another solution,,??
I really need to..really appreciate your reply
thanks

Re: Why JFolder::makeSafe removes dot ?

Posted: Sat Oct 20, 2012 8:08 am
by JohnDevise
haniar wrote:is ther any solution yet ?
i have the same problem here on my joomla 1.7
can someone answer another solution,,??
I really need to..really appreciate your reply
thanks
Hi haniar .
Try this solution with patches . I'm not sure , but maybe it's help you - joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=16506