Bug 1448071 - Support UNC paths for spell check dictionaries. r?masayuki draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 23 Mar 2018 21:29:16 +0900
changeset 771568 c39894772f672caf82b827966e91d6a6e6c5ff25
parent 771093 7771df14ea181add1dc4133f0f5559bf620bf976
child 772157 a7bfaf987a23968b626b8157f8f364d9705a813c
push id103716
push userVYV03354@nifty.ne.jp
push dateFri, 23 Mar 2018 12:30:21 +0000
reviewersmasayuki
bugs1448071
milestone61.0a1
Bug 1448071 - Support UNC paths for spell check dictionaries. r?masayuki MozReview-Commit-ID: 5Ig2SZKf44R
extensions/spellcheck/hunspell/glue/mozHunspell.cpp
--- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp
+++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp
@@ -163,20 +163,27 @@ NS_IMETHODIMP mozHunspell::SetDictionary
     return NS_ERROR_FILE_NOT_FOUND;
 
   nsAutoCString dictFileName, affFileName;
 
 #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
+  // Hunspell 1.3.3+ supports UTF-8 file paths on Windows
   // by prefixing "\\\\?\\".
-  affFileName.AssignLiteral("\\\\?\\");
-  AppendUTF16toUTF8(affFileNameU, affFileName);
+  if (StringBeginsWith(affFileNameU, NS_LITERAL_STRING("\\\\"))) {
+    CopyUTF16toUTF8(affFileNameU, affFileName);
+    if (affFileNameU.CharAt(2) != u'?') {
+      affFileName.InsertLiteral("?\\UNC\\", 2);
+    }
+  } else {
+    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;