Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

space character in filename is URL-encoded #3184

Open
neil-pearce opened this issue Mar 22, 2022 · 8 comments · May be fixed by #3253
Open

space character in filename is URL-encoded #3184

neil-pearce opened this issue Mar 22, 2022 · 8 comments · May be fixed by #3253
Assignees
Labels

Comments

@neil-pearce
Copy link

neil-pearce commented Mar 22, 2022

Expected behavior

The current directory path should be able to contain a space character

Actual behavior

A space character results in %20 in the path name, eg a path containing the directory 'TEST DATA' results in 'TEST%20DATA' and the output and cache directories are generated with their default values (eg .phpdoc/cache) with a new parallel directory structure beginning at the URL encoded sub-directory is created for .phpdoc/build

Steps to reproduce the problem

  1. Create a directory path containing a sub-directory with a space in the name
  2. Run phpDocumentor from under that path

Your environment

  • Version used: phpdocumentor-3.3.1-rc
  • Install method: PHIVE
  • PHP version: PHP 8.1.4 (cli) (built: Mar 16 2022 09:33:31) (ZTS Visual C++ 2019 x64)
  • Operating system and version: Windows 10

The issue is being caused because the function createFromWindowsPath in League\Uri is performing a rawurlencode on the elements of the filename:
$uri = implode('/', array_map('rawurlencode', explode('/', $uri)));

The attached file is one possible solution to the problem (note that WINDOWS_URI_FORMAT has been modified, in addition to the code changes):
createUri.txt

@phpdoc-bot phpdoc-bot added this to Needs triage in phpDoc issue triage board Mar 22, 2022
@web-cooking-factory
Copy link

Hi ! Nobody ?
Exact same thing here ...

@mvriel
Copy link
Member

mvriel commented Jul 9, 2022

Thanks for reporting this issue. You are right and this does seem to be an issue with using league/uri's path value object. This is a similar issue to #3247 and #3239; for some reason our test cases did not pick up on this.

As mentioned in 3239, we'd need a bit of time to fix this because we resolve paths across operating systems but also across virtual filesystems. And since the problem may be in the nature of League URI's path object itself, I have a gut feeling that we need to rip that out and replace it with something that works better.

@mvriel
Copy link
Member

mvriel commented Jul 9, 2022

A Draft PR is opened at #3253 containing at least a couple of test cases illustrating the issue. I still need to discern what more locations there may be, and what scenario's I am still missing

@mvriel
Copy link
Member

mvriel commented Jul 9, 2022

The issue is being caused because the function createFromWindowsPath in League\Uri is performing a rawurlencode on the elements of the filename:

Thank you for your research, I'm not sure I would have found this easily. My testcases also seem to indicate there is a similar issue in a non-windows environment. Which makes this even more interesting

@neil-pearce
Copy link
Author

I was afraid that it wouldn't be a simple - I basically don't have a grasp of all the complexities. Thanks for picking it up

@mvriel
Copy link
Member

mvriel commented Jul 22, 2022

The first few tries to fix it haven't worked so far; I need to refactor quite a bit because of assumption errors. It also doesn't help that our Windows unit tests won't run at the moment..

@A2020GK
Copy link

A2020GK commented Apr 10, 2023

My problem is quite large: directory name, that's in Russian!
I've got a lot of problems with OneDrive.

@michalb314
Copy link

michalb314 commented Nov 8, 2023

Was this fixed? I have the same problem, trying to generate docs for a site hosted in Local, folder is inside "Local Sites", docs get generated in "Local%20Sites". Annoying to say the least.

EDIT: actually, no docs are generated - the space messes everything up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
phpDoc issue triage board
  
High priority
5 participants