Why JFolder::makeSafe removes dot ?

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
Forum rules
Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
meloman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 106
Joined: Sun Oct 22, 2006 1:29 am
Location: Montréal
Contact:

Why JFolder::makeSafe removes dot ?

Post by meloman » Sat May 23, 2009 3:59 pm

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.
http://aldra.ca :: My latest little projects

User avatar
airton
Joomla! Ace
Joomla! Ace
Posts: 1369
Joined: Sun Nov 04, 2007 1:12 am
Location: Brazil
Contact:

Re: Why JFolder::makeSafe removes dot ?

Post by airton » Sun May 24, 2009 11:46 pm

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,
Airton Torres
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.

User avatar
meloman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 106
Joined: Sun Oct 22, 2006 1:29 am
Location: Montréal
Contact:

Re: Why JFolder::makeSafe removes dot ?

Post by meloman » Mon May 25, 2009 11:21 am

Thanks, I will try that tonight !
http://aldra.ca :: My latest little projects

User avatar
meloman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 106
Joined: Sun Oct 22, 2006 1:29 am
Location: Montréal
Contact:

Re: Why JFolder::makeSafe removes dot ?

Post by meloman » Mon May 25, 2009 10:51 pm

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!
http://aldra.ca :: My latest little projects

robert101083
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Wed Oct 10, 2007 12:39 pm

Re: Why JFolder::makeSafe removes dot ?

Post by robert101083 » Thu Jun 24, 2010 3:10 am

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

User avatar
airton
Joomla! Ace
Joomla! Ace
Posts: 1369
Joined: Sun Nov 04, 2007 1:12 am
Location: Brazil
Contact:

Re: Why JFolder::makeSafe removes dot ?

Post by airton » Fri Jun 25, 2010 3:33 am

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.
Airton Torres
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.

User avatar
meloman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 106
Joined: Sun Oct 22, 2006 1:29 am
Location: Montréal
Contact:

Re: Why JFolder::makeSafe removes dot ?

Post by meloman » Fri Jun 25, 2010 4:11 am

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!
http://aldra.ca :: My latest little projects

robert101083
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Wed Oct 10, 2007 12:39 pm

Re: Why JFolder::makeSafe removes dot ?

Post by robert101083 » Fri Jun 25, 2010 4:15 am

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

marty79
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Feb 23, 2011 5:58 pm

Re: Why JFolder::makeSafe removes dot ?

Post by marty79 » Wed Feb 23, 2011 6:00 pm

bumping this as JFolder is still removing the dot and is breaking perfectly valid installations

K_koo
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sun Sep 25, 2011 9:54 pm

Re: Why JFolder::makeSafe removes dot ?

Post by K_koo » Sun Nov 27, 2011 3:48 pm

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!

haniar
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Dec 02, 2011 3:18 am

Re: Why JFolder::makeSafe removes dot ?

Post by haniar » Fri Dec 02, 2011 3:56 am

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

User avatar
JohnDevise
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon Sep 24, 2012 9:34 am
Location: USA
Contact:

Re: Why JFolder::makeSafe removes dot ?

Post by JohnDevise » Sat Oct 20, 2012 8:08 am

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


Locked

Return to “Joomla! 1.5 Bug Reporting”