Bug 801780 - Part 1: Escape quotes in memory reporter paths when dumping to JSON. r=njn
authorJustin Lebar <justin.lebar@gmail.com>
Wed, 17 Oct 2012 10:44:31 -0400
changeset 110680 6d4ffa88e7d3c0e7f02fd1c13f8630b4658269db
parent 110679 542a978f042cbcaeeef75e89d9a818c35e5fb287
child 110681 b803ce91fc0ebaf17d59c913d437a8fe08759fc7
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersnjn
bugs801780
milestone19.0a1
Bug 801780 - Part 1: Escape quotes in memory reporter paths when dumping to JSON. r=njn
xpcom/base/MemoryInfoDumper.cpp
--- a/xpcom/base/MemoryInfoDumper.cpp
+++ b/xpcom/base/MemoryInfoDumper.cpp
@@ -394,17 +394,18 @@ DumpReport(nsIGZFileWriter *aWriter, boo
   unsigned pid = getpid();
   processId.Append(nsPrintfCString("(pid %u)", pid));
 
   DUMP(aWriter, "\n    {\"process\": \"");
   DUMP(aWriter, processId);
 
   DUMP(aWriter, "\", \"path\": \"");
   nsCString path(aPath);
-  path.ReplaceSubstring("\\", "\\\\");    // escape backslashes for JSON
+  path.ReplaceSubstring("\\", "\\\\");    /* <backslash> --> \\ */
+  path.ReplaceSubstring("\"", "\\\"");    // " --> \"
   DUMP(aWriter, path);
 
   DUMP(aWriter, "\", \"kind\": ");
   DUMP(aWriter, nsPrintfCString("%d", aKind));
 
   DUMP(aWriter, ", \"units\": ");
   DUMP(aWriter, nsPrintfCString("%d", aUnits));