Bug 1587551 - Fix address book CSV export when Notes field contains quotation marks. r+a=jorgk
authorJonathan Kamens <jik@kamens.us>
Wed, 09 Oct 2019 23:00:01 +0200
changeset 36696 08f3db86ac9aa66ba1dfafb2dfdb70819c210255
parent 36695 2ecd5527f4bd2043d89e37010bd5ab952cc00e60
child 36697 0e203dc1c0338a650d2fe3b2aed097cfadfdf7f7
push id394
push userclokep@gmail.com
push dateMon, 21 Oct 2019 20:22:01 +0000
bugs1587551
Bug 1587551 - Fix address book CSV export when Notes field contains quotation marks. r+a=jorgk
mailnews/addrbook/src/nsAbManager.cpp
--- a/mailnews/addrbook/src/nsAbManager.cpp
+++ b/mailnews/addrbook/src/nsAbManager.cpp
@@ -750,18 +750,17 @@ nsresult nsAbManager::ExportDirectoryToD
                 int32_t match = 0;
                 uint32_t offset = 0;
                 nsString oldSubstr = NS_LITERAL_STRING("\"");
                 nsString newSubstr = NS_LITERAL_STRING("\"\"");
                 while (offset < newValue.Length()) {
                   match = newValue.Find(oldSubstr, offset);
                   if (match == -1) break;
 
-                  newValue.Replace(offset + match, oldSubstr.Length(),
-                                   newSubstr);
+                  newValue.Replace(match, oldSubstr.Length(), newSubstr);
                   offset += (match + newSubstr.Length());
                 }
               }
               if (!needsQuotes && (newValue.FindChar(',') != -1 ||
                                    newValue.FindChar('\x09') != -1))
                 needsQuotes = true;
 
               // Make sure we quote if containing CR/LF.