Issue #1772 - Stop using legacy code page conversion for file paths on Linux.

OS.File already only supports UTF-8 paths on non-Windows systems, so this change
makes our different ways of accessing file paths consistent with each other.
This should prevent unexpected crashes in glibc that expect UTF-8.

This resolves #1772.
This commit is contained in:
Moonchild 2021-05-14 12:25:57 +00:00 • committed by roytam1
commit 8744911c18
3 changed files with 15 additions and 891 deletions

View file

@ -14,9 +14,13 @@
* *** THESE ARE NOT GENERAL PURPOSE CONVERTERS *** *
* *
* NS_CopyNativeToUnicode / NS_CopyUnicodeToNative should only be used *
* for converting *FILENAMES* between native and unicode. They are not *
* for converting *FILENAMES* between bytes and UTF-16. They are not *
* designed or tested for general encoding converter use. *
* *
* On Windows, these functions convert to and from the system's legacy *
* code page, which cannot represent all of Unicode. Elsewhere, these *
* convert to and from UTF-8. *
* *
\*****************************************************************************/
/**
@ -33,25 +37,15 @@ nsresult NS_CopyUnicodeToNative(const nsAString& aInput, nsACString& aOutput);
* name in UTF-8 out of nsIFile, we can just use |GetNativeLeafName| rather
* than using |GetLeafName| and converting the result to UTF-8 if the file
* system encoding is UTF-8.
* On Unix, it depends on the locale and is not known in advance (at the
* compilation time) so that this function needs to be a real function.
* On Windows and other platforms (e.g. OS2), it's never UTF-8.
*/
#if defined(XP_UNIX)
bool NS_IsNativeUTF8();
#else
inline bool
NS_IsNativeUTF8()
{
#ifdef XP_WIN
return false;
}
#else
return true;
#endif
/**
* internal
*/
void NS_StartupNativeCharsetUtils();
void NS_ShutdownNativeCharsetUtils();
}
#endif // nsNativeCharsetUtils_h__