Bug 1421123 - Stop using GetNativePath in hunspell. r?masayuki draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 05 Dec 2017 22:09:52 +0900
changeset 707532 26df802590a2288a040c1832eec0cd1630b6326a
parent 707531 12e092e2b1874063d08fc4c7767d6ed1da312546
child 742966 cab13eb14f3a0bae2ecbd2ee266adb6fc20ebed5
push id92142
push userVYV03354@nifty.ne.jp
push dateTue, 05 Dec 2017 13:10:45 +0000
reviewersmasayuki
bugs1421123
milestone59.0a1
Bug 1421123 - Stop using GetNativePath in hunspell. r?masayuki MozReview-Commit-ID: Gh0THT6kEnI
extensions/spellcheck/hunspell/glue/mozHunspell.cpp
--- 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;