lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
245 stars 17 forks source link

9907291855: Conversion from NSURL to a classic HFS path is incorrect when POSIX path contains a legal ":" character #21310

Open openradar-mirror opened 5 years ago

openradar-mirror commented 5 years ago

Description

FB7291855

When calling CFURLCopyFileSystemPath(path, 1) in order to get a HFS style path, this returns incorrect results when the path contains a folder with a colon (or slash) in its name.

I understand that this particular function is marked deprecated, but HFS paths are still needed in some parts of the OS API, e.g. when passing file refs to AppleScripts, and so this should still work correctly, at least, when needed. And I'm suspect it used to work correctly, but got broken a while ago.

How to reproduce the bug:

In Xcode, create a new "command line" project and use the attached main.m file. Run the program - it'll create a file named "FolderEndingInSlash/" inside "/tmp", when you look at the tmp folder with Finder (where ":" in a POSIX file name appears as a "/").

Then it calls CFURLCopyFileSystemPath to get the HFS path, which correctly would be:

Macintosh HD:private:tmp:FolderEndingInSlash/

However, the "/" at the end is missing.

The reason for this bug seems to be that this function calls stringByStandardizingPath afterwards, which strips the slash by mistake.

You can read more about this here: https://stackoverflow.com/a/57948775/43615

- Product Version: 10.14 Created: 2019-09-18T16:13:22.113994 Originated: 18Sept19 Open Radar Link: http://www.openradar.me/9907291855