Bug 1421123 - Stop using GetNativePath in hunspell. r?masayuki
MozReview-Commit-ID: Gh0THT6kEnI
--- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp
+++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp
@@ -159,23 +159,28 @@ NS_IMETHODIMP mozHunspell::SetDictionary
}
nsIFile* affFile = mDictionaries.GetWeak(nsDependentString(aDictionary));
if (!affFile)
return NS_ERROR_FILE_NOT_FOUND;
nsAutoCString dictFileName, affFileName;
- // XXX This isn't really good. nsIFile->NativePath isn't safe for all
- // character sets on Windows.
- // A better way would be to QI to nsIFile, and get a filehandle
- // from there. Only problem is that hunspell wants a path
-
+#ifdef XP_WIN
+ nsAutoString affFileNameU;
+ nsresult rv = affFile->GetPath(affFileNameU);
+ NS_ENSURE_SUCCESS(rv, rv);
+ // Hunspell 1.5+ supports UTF-8 file paths on Windows
+ // by prefixing "\\\\?\\".
+ affFileName.AssignLiteral("\\\\?\\");
+ AppendUTF16toUTF8(affFileNameU, affFileName);
+#else
nsresult rv = affFile->GetNativePath(affFileName);
NS_ENSURE_SUCCESS(rv, rv);
+#endif
if (mAffixFileName.Equals(affFileName.get()))
return NS_OK;
dictFileName = affFileName;
int32_t dotPos = dictFileName.RFindChar('.');
if (dotPos == -1)
return NS_ERROR_FAILURE;