pheditor icon indicating copy to clipboard operation
pheditor copied to clipboard

BUG? Are SPACES in the Directory Name forbidden?

Open gaffling opened this issue 3 years ago • 4 comments

The Edit function can't call the file if there are SPACES in the Directory Name.

Is there are Workaround?

Thanks for this very nice Tool (y)

gaffling avatar Oct 29 '20 12:10 gaffling

It looks like urlencode is missing. Adding urlencode seems to work with spaces, side-effects unknown/untested. The path on the header is not decoded and then displayed encoded. To add urlencode change

			$dirs_html .= '<li class="dir"><a href="#/' . $dir_path . '/" class="open-dir" data-dir="/' . $dir_path . '/">' . $file . '</a>' . files($dir . DS . $file, false) . '</li>';
		} else if (empty(PATTERN_FILES) || preg_match(PATTERN_FILES, $file)) {
			$file_path = str_replace(MAIN_DIR . DS, '', $dir . DS . $file);

			$files_html .= '<li class="file ' . (is_writable($file_path) ? 'editable' : null) . '" data-jstree=\'{ "icon" : "jstree-file" }\'><a href="#/' . $file_path . '" data-file="/' . $file_path . '" class="open-file">' . $file . '</a></li>';

to

			$dirs_html .= '<li class="dir"><a href="#/' . urlencode($dir_path) . '/" class="open-dir" data-dir="/' . urlencode($dir_path) . '/">' . $file . '</a>' . files($dir . DS . $file, false) . '</li>';
		} else if (empty(PATTERN_FILES) || preg_match(PATTERN_FILES, $file)) {
			$file_path = str_replace(MAIN_DIR . DS, '', $dir . DS . $file);

			$files_html .= '<li class="file ' . (is_writable($file_path) ? 'editable' : null) . '" data-jstree=\'{ "icon" : "jstree-file" }\'><a href="#/' . urlencode($file_path) . '" data-file="/' . urlencode($file_path) . '" class="open-file">' . $file . '</a></li>';

ITSBed avatar Oct 30 '20 11:10 ITSBed

A good tip in the right direction, but then of course / will be replaced and that will ruin it. I solved it nowt with a str_replace(' ', '+', $string) and it works for me - thanks for your help

gaffling avatar Oct 30 '20 12:10 gaffling

but then of course / will be replaced and that will ruin it

Really? I tried it and it's working for me - since the encoded / = %2F will get decoded again, too. Am I missing something?

ITSBed avatar Oct 30 '20 12:10 ITSBed

I'm using MAMP on OSx on iMac - but that should not be a reason for that. Can't say, only with replace it works for me correctly - but that's fine

gaffling avatar Oct 30 '20 12:10 gaffling