revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.07k stars 196 forks source link

fix(osx): Crash when selecting a UTF-8 folder name #1067

Closed bryphe closed 3 years ago

bryphe commented 3 years ago

From https://github.com/onivim/oni2/issues/3519

Issue: When selecting a folder on OSX with Unicode characters, Revery crashes.

Defect: We were converting the returned string using:

cStringUsingEncoding:NSASCIIStringEncoding

That API returns NULL if the string cannot be losslessly encoded in the target format. In the case of a folder with Unicode characters, this API would return null, and the API was assuming that we'd always get a valid string.

Fix: Two fixes: 1) Use UTF-8 encoding instead of ASCII, so that the API can handle Unicode 2) Handle the NULL case more reliably - if there happens to be a folder we can't convert, don't segfault, skip it.