Bug 1393230 - Part 2: Fix more improper string usages. r=njn
☠☠ backed out by 7e21f710ecec ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Thu, 31 Aug 2017 15:52:30 -0700
changeset 429043 f762f605dd83fc6331161a33e1ef5d54cafbd08d
parent 429042 c366bfc13e86c94389d58ffc41c9f4a3e573d406
child 429044 9115364cd4aa078c49bba7911069f8178e55166f
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;