Bug 1317241 - Replace string literals containing escaped characters with raw string literals in dom/. draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Mon, 14 Nov 2016 11:45:55 +0200
changeset 439080 579ca257968707cc1ab534b5d0f5516a1c28138c
parent 439079 7a13ece91e795c18ed8516cc664b9a4230a68f73
child 439081 1e52820a97ba3d9901de5c8a5e1da59e56099bc9
push id35900
push userbmo:bpostelnicu@mozilla.com
push dateTue, 15 Nov 2016 11:06:22 +0000
bugs1317241
milestone53.0a1
Bug 1317241 - Replace string literals containing escaped characters with raw string literals in dom/. MozReview-Commit-ID: FGjPRf0g3Yt
dom/base/nsContentUtils.cpp
dom/base/nsGlobalWindow.cpp
dom/indexedDB/ActorsParent.cpp
dom/ipc/ContentChild.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4551,32 +4551,32 @@ nsContentUtils::CreateContextualFragment
           tagName.AppendLiteral(" xmlns"); // space important
           if (name->GetPrefix()) {
             tagName.Append(char16_t(':'));
             name->LocalName()->ToString(nameStr);
             tagName.Append(nameStr);
           } else {
             setDefaultNamespace = true;
           }
-          tagName.AppendLiteral("=\"");
+          tagName.AppendLiteral(R"(=")");
           tagName.Append(uriStr);
           tagName.Append('"');
         }
       }
     }
 
     if (!setDefaultNamespace) {
       mozilla::dom::NodeInfo* info = content->NodeInfo();
       if (!info->GetPrefixAtom() &&
           info->NamespaceID() != kNameSpaceID_None) {
         // We have no namespace prefix, but have a namespace ID.  Push
         // default namespace attr in, so that our kids will be in our
         // namespace.
         info->GetNamespaceURI(uriStr);
-        tagName.AppendLiteral(" xmlns=\"");
+        tagName.AppendLiteral(R"( xmlns=")");
         tagName.Append(uriStr);
         tagName.Append('"');
       }
     }
 
     content = content->GetParent();
   }
 
@@ -9094,19 +9094,19 @@ StartElement(Element* aContent, StringBu
       nsIAtom* prefix = name->GetPrefix();
       if (prefix) {
         aBuilder.Append(prefix);
         aBuilder.Append(":");
       }
     }
 
     aBuilder.Append(attName);
-    aBuilder.Append("=\"");
+    aBuilder.Append(R"(=")");
     AppendEncodedAttributeValue(attValue, aBuilder);
-    aBuilder.Append("\"");
+    aBuilder.Append(R"(")");
   }
 
   aBuilder.Append(">");
 
   /*
   // Per HTML spec we should append one \n if the first child of
   // pre/textarea/listing is a textnode and starts with a \n.
   // But because browsers haven't traditionally had that behavior,
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8551,19 +8551,19 @@ nsGlobalWindow::PostMessageMozOuter(JSCo
             NS_FAILED(principal->GetOrigin(targetOrigin)) ||
             NS_FAILED(aSubjectPrincipal.GetOrigin(sourceOrigin))) {
           NS_WARNING("Failed to get source and target origins");
           return;
         }
 
         nsContentUtils::LogSimpleConsoleError(
           NS_ConvertUTF8toUTF16(nsPrintfCString(
-            "Attempting to post a message to window with url \"%s\" and "
-            "origin \"%s\" from a system principal scope with mismatched "
-            "origin \"%s\".",
+            R"(Attempting to post a message to window with url "%s" and )"
+            R"(origin "%s" from a system principal scope with mismatched )"
+            R"(origin "%s".)",
             targetURL.get(), targetOrigin.get(), sourceOrigin.get())),
           "DOM");
 
         attrs = principal->OriginAttributesRef();
       }
     }
 
     // Create a nsIPrincipal inheriting the app/browser attributes from the
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -17653,19 +17653,19 @@ QuotaClient::InitOrigin(PersistenceType 
       MOZ_ASSERT(!StringEndsWith(leafName, journalSuffix));
       MOZ_ASSERT(!StringEndsWith(leafName, shmSuffix));
       MOZ_ASSERT(!StringEndsWith(leafName, walSuffix));
 
       nsString path;
       MOZ_ALWAYS_SUCCEEDS(unknownFile->GetPath(path));
       MOZ_ASSERT(!path.IsEmpty());
 
-      nsPrintfCString warning("Refusing to open databases for \"%s\" because "
-                              "an unexpected file exists in the storage "
-                              "area: \"%s\"",
+      nsPrintfCString warning(R"(Refusing to open databases for "%s" because )"
+                              R"(an unexpected file exists in the storage )"
+                              R"(area: "%s")",
                               PromiseFlatCString(aOrigin).get(),
                               NS_ConvertUTF16toUTF8(path).get());
       NS_WARNING(warning.get());
     }
 #endif
     return NS_ERROR_UNEXPECTED;
   }
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -3284,17 +3284,17 @@ ContentChild::FatalErrorIfNotUsingGPUPro
   // want to crash normally. Otherwise we want to just warn as the other end
   // must be the GPU process and it crashing shouldn't be fatal for us.
   if (aOtherPid == base::GetCurrentProcId() ||
       (GetSingleton() && GetSingleton()->OtherPid() == aOtherPid)) {
     mozilla::ipc::FatalError(aProtocolName, aErrorMsg, false);
   } else {
     nsAutoCString formattedMessage("IPDL error [");
     formattedMessage.AppendASCII(aProtocolName);
-    formattedMessage.AppendLiteral("]: \"");
+    formattedMessage.AppendLiteral(R"(]: ")");
     formattedMessage.AppendASCII(aErrorMsg);
-    formattedMessage.AppendLiteral("\".");
+    formattedMessage.AppendLiteral(R"(".)");
     NS_WARNING(formattedMessage.get());
   }
 }
 
 } // namespace dom
 } // namespace mozilla