From ff29b77edc5d0eb65139d91c6170ed23d18cb28f Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 17 Mar 2020 20:14:22 +0100 Subject: [PATCH] Issue #1467 - Part 3: Use UTF-8 file paths for NSS-SQL database. --- security/manager/ssl/nsNSSComponent.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index d505b8abae..6d1e3c5f78 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -1706,16 +1706,25 @@ GetNSSProfilePath(nsAutoCString& aProfilePath) } #if defined(XP_WIN) - // Native path will drop Unicode characters that cannot be mapped to system's - // codepage, using short (canonical) path as workaround. nsCOMPtr profileFileWin(do_QueryInterface(profileFile)); if (!profileFileWin) { MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Could not get nsILocalFileWin for profile directory.\n")); return NS_ERROR_FAILURE; } - rv = profileFileWin->GetNativeCanonicalPath(aProfilePath); +#ifdef NSS_SQLSTORE + // SQLite always takes UTF-8 file paths regardless of the current system + // code page. + nsAutoString u16ProfilePath; + rv = profileFileWin->GetCanonicalPath(u16ProfilePath); + CopyUTF16toUTF8(u16ProfilePath, aProfilePath); #else + // Native path will drop Unicode characters that cannot be mapped to system's + // codepage, using short (canonical) path as workaround. + rv = profileFileWin->GetNativeCanonicalPath(aProfilePath); +#endif +#else + // On non-Windows, just get the native profile path. rv = profileFile->GetNativePath(aProfilePath); #endif