swift-toolkit icon indicating copy to clipboard operation
swift-toolkit copied to clipboard

Replace `String` by `URL` when dealing with path (absolutes and relatives)

Open ghost opened this issue 8 years ago • 3 comments

In many place of the framework we use String in order to deal with paths, then have to cast them to NSString in order to use methods like .appendPathComponent etc. .

Using URL directly where we use String for path would be more secure and prevent casting.

ghost avatar Mar 14 '17 14:03 ghost

Note for anyone tackling this issue: Link.href can be templated and thus should stay as a String, because the conversion with URL loses information.

mickael-menu-mantano avatar Mar 18 '19 14:03 mickael-menu-mantano

@mmenu-mantano can we close this issue then?

aferditamuriqi avatar May 17 '19 17:05 aferditamuriqi

No it's actually not done yet, I commented this to make sure that the person tackling this issue wouldn't convert the Link.href to an URL, as it would break templated Links.

By the way, I think this issue is quite important because I already got problems (in another app) using paths for String directly, because of APFS's Unicode normalization. This occurs when using for example accentuated characters in filenames. Using URL is usually safer in this case.

https://eclecticlight.co/2017/04/06/apfs-is-currently-unusable-with-most-non-english-languages/

mickael-menu-mantano avatar May 20 '19 07:05 mickael-menu-mantano