Bug 1393230 - Part 2: Fix more improper string usages. r=njn
authorEric Rahm <erahm@mozilla.com>
Thu, 31 Aug 2017 15:52:30 -0700
changeset 428972 a1bcb487ffecfe2573e53c4239e59cd71ec87a7c
parent 428971 ac28b19fc28360c6c9eadbadc30478aa3f1a0f76
child 428973 8b18f545fd6f7dd341010b041bd248a1e726bc13
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1393230
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1393230 - Part 2: Fix more improper string usages. r=njn This fixes improper usages of Find where an offset was actually being use for the boolean ignore case flag. It also fixes a few instances of passing in a literal wchar_t to our functions where a NS_LITERAL_STRING or char16_t should be used instead.
security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
toolkit/system/osxproxy/ProxyUtils.mm
toolkit/system/windowsproxy/ProxyUtils.cpp
toolkit/xre/nsGDKErrorHandler.cpp
widget/windows/IMMHandler.cpp
xpcom/io/nsLocalFileWin.cpp
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
@@ -88,17 +88,17 @@ CacheDirAndAutoClear(nsIProperties* aDir
     return;
   }
 
   *cacheVar = MakeUnique<nsString>();
   ClearOnShutdown(cacheVar);
   MOZ_ALWAYS_SUCCEEDS(dirToCache->GetPath(**cacheVar));
 
   // Convert network share path to format for sandbox policy.
-  if (Substring(**cacheVar, 0, 2).Equals(L"\\\\")) {
+  if (Substring(**cacheVar, 0, 2).Equals(NS_LITERAL_STRING("\\\\"))) {
     (*cacheVar)->InsertLiteral(u"??\\UNC", 1);
   }
 }
 
 /* static */
 void
 SandboxBroker::CacheRulesDirectories()
 {
--- a/toolkit/system/osxproxy/ProxyUtils.mm
+++ b/toolkit/system/osxproxy/ProxyUtils.mm
@@ -153,17 +153,17 @@ IsMatchWildcard(const nsACString& aHost,
           return true;
         }
       }
     } else {
       if (tokenEnd == -1) {
         tokenEnd = overrideLength; // no '*' char, match rest of string
       }
       nsAutoCString token(Substring(override, tokenStart, tokenEnd - tokenStart));
-      offset = host.Find(token, offset);
+      offset = host.Find(token, /* aIgnoreCase = */ false, offset);
       if (offset == -1 || (!star && offset)) {
         return false;
       }
       star = false;
       tokenStart = tokenEnd;
       offset += token.Length();
     }
   }
--- a/toolkit/system/windowsproxy/ProxyUtils.cpp
+++ b/toolkit/system/windowsproxy/ProxyUtils.cpp
@@ -153,17 +153,17 @@ IsMatchWildcard(const nsACString& aHost,
           return true;
         }
       }
     } else {
       if (tokenEnd == -1) {
         tokenEnd = overrideLength; // no '*' char, match rest of string
       }
       nsAutoCString token(Substring(override, tokenStart, tokenEnd - tokenStart));
-      offset = host.Find(token, offset);
+      offset = host.Find(token, /* aIgnoreCase = */ false, offset);
       if (offset == -1 || (!star && offset)) {
         return false;
       }
       star = false;
       tokenStart = tokenEnd;
       offset += token.Length();
     }
   }
--- a/toolkit/xre/nsGDKErrorHandler.cpp
+++ b/toolkit/xre/nsGDKErrorHandler.cpp
@@ -62,17 +62,18 @@ GdkErrorHandler(const gchar *log_domain,
       NS_RUNTIMEABORT(message);
 
     errno = 0;
     event.request_code = strtol(endptr + requestCodeString.Length(), &endptr, 10);
     if (errno)
       NS_RUNTIMEABORT(message);
 
     NS_NAMED_LITERAL_CSTRING(minorCodeString, " minor_code ");
-    start = buffer.Find(minorCodeString, endptr - buffer.BeginReading());
+    start = buffer.Find(minorCodeString, /* aIgnoreCase = */ false,
+                        endptr - buffer.BeginReading());
     if (!start)
       NS_RUNTIMEABORT(message);
 
     errno = 0;
     event.minor_code = strtol(buffer.BeginReading() + start + minorCodeString.Length(), nullptr, 10);
     if (errno)
       NS_RUNTIMEABORT(message);
 
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -297,18 +297,18 @@ IMMHandler::IsJapanist2003Active()
 }
 
 // static
 bool
 IMMHandler::IsGoogleJapaneseInputActive()
 {
   // NOTE: Even on Windows for en-US, the name of Google Japanese Input is
   //       written in Japanese.
-  return sIMEName.Equals(L"Google \x65E5\x672C\x8A9E\x5165\x529B "
-                         L"IMM32 \x30E2\x30B8\x30E5\x30FC\x30EB");
+  return sIMEName.Equals(u"Google \x65E5\x672C\x8A9E\x5165\x529B "
+                         u"IMM32 \x30E2\x30B8\x30E5\x30FC\x30EB");
 }
 
 // static
 bool
 IMMHandler::ShouldDrawCompositionStringOurselves()
 {
   // If current IME has special UI or its composition window should not
   // positioned to caret position, we should now draw composition string
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -1019,19 +1019,19 @@ nsLocalFile::ResolveAndStat()
   // we can't resolve/stat anything that isn't a valid NSPR addressable path
   if (mWorkingPath.IsEmpty()) {
     return NS_ERROR_FILE_INVALID_PATH;
   }
 
   // this is usually correct
   mResolvedPath.Assign(mWorkingPath);
 
-  // slutty hack designed to work around bug 134796 until it is fixed
-  nsAutoString nsprPath(mWorkingPath.get());
-  if (mWorkingPath.Length() == 2 && mWorkingPath.CharAt(1) == L':') {
+  // Make sure root paths have a trailing slash.
+  nsAutoString nsprPath(mWorkingPath);
+  if (mWorkingPath.Length() == 2 && mWorkingPath.CharAt(1) == u':') {
     nsprPath.Append('\\');
   }
 
   // first we will see if the working path exists. If it doesn't then
   // there is nothing more that can be done
   nsresult rv = GetFileInfo(nsprPath, &mFileInfo64);
   if (NS_FAILED(rv)) {
     return rv;