Tilde(~) in Path Breaks CI4 (used in iCloud Drive Path) |
CI4 breaks when it encounters a path that has a tilde(~) in it.
Unfortunately, Apple uses tildes in its iCloud Drive path name, which is rendered as: Code: /Users/username/Library/Mobile Documents/com~apple~CloudDocs When using PHP's built-in web server on MacOS: Code: cd /Users/moo/Library/Mobile Documents/com~apple~CloudDocs/Sites/ci4b1/ Code: /Users/myname/Sites/ci4b1/ Code: /Users/myname/Library/Mobile Documents/com~apple~CloudDocs/Sites/ci4b1/ Code: Fatal error: Uncaught Error: Class 'Config\App' not found in /Users/myname/Library/Mobile Documents/com~apple~CloudDocs/Sites/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php on line 139 The same fatal error returns when executing spark at the CLI if the CI4 folder is located in a path containing a tilde(~) . Code: ➜ ci4b1 pwd (Using CodeIgniter since 1.x)
Does anyone have an idea of how we can work around this?
The error occurs in the final line of /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php in createClass where we are creating a new class instance using the name that was passed in. vendor/codeigniter4/framework/system/Config/Config::createClass(string $name): Code: /** (Using CodeIgniter since 1.x)
From what I have read it's a short cut for you home folder.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-05-2019, 04:27 AM)InsiteFX Wrote: From what I have read it's a short cut for you home folder. Yes, it is the actual path to the mount points for MacOS iCloud Drive/ and iOS "Files" app. Since that remote storage mechanism is so useful for developers using MacOS, I'm trying to figure out how to get CodeIgniter 4 working there. (Using CodeIgniter since 1.x)
If you can get the path to the short cut then you should be able to just enter that
as the url link. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Well, the obvious answer is don't store it in the iCloud drive
Here's a workaround to expand the filenames, though I'm not sure how many different places would need to use that. I'm also unconvinced it's a good thing to have in core as it feels like it could be a security issue, though I'd have to think for a bit on when it could be safe and when not.
The issue is caused by the sanitizeFilename method on line 301 of the file vendor/codeigniter4/framework/system/Autoloader/Autoloader.php. The function transforms a path such as /com~apple~CloudDocs/sites, which is perfectly legitimate on a Mac, into /comappleCloudDocs/sites, rendering all paths invalid.
I solved the issue by changing line 307: PHP Code: $filename = preg_replace('/[^0-9\p{L}\s\/\-\_\.\:\\\\]/u', '', $filename); PHP Code: $filename = preg_replace('/[^0-9\p{L}\s\/\-\_\.\:\\\\~]/u', '', $filename); |
Welcome Guest, Not a member yet? Register Sign In |