diff -Nur sogo-connector-3.104-nightly-20110130\chrome\content\sogo-connector\general\vcards.utils.js sogo-connector-3.104-nightly-20110130-patched\chrome\content\sogo-connector\general\vcards.utils.js
--- sogo-connector-3.104-nightly-20110130\chrome\content\sogo-connector\general\vcards.utils.js	Sun Jan 30 07:44:44 2011
+++ sogo-connector-3.104-nightly-20110130-patched\chrome\content\sogo-connector\general\vcards.utils.js	Mon Jan 31 15:23:20 2011
@@ -38,14 +38,19 @@
 jsInclude(["chrome://inverse-library/content/uuid.js",
            "chrome://inverse-library/content/quoted-printable.js"]);
 
+/* Individually escape COMMA separated components of value list */
+function escapedForCardList(theString) {
+    let theList = theString.split(",");
+    for (let k in theList)
+        theList[k] = escapedForCard(theList[k]);
+    return theList.join(",");
+}
+
 function escapedForCard(theString) {
     theString = theString.replace(/\\/g, "\\\\");
     theString = theString.replace(/,/g, "\\,");
     theString = theString.replace(/;/g, "\\;");
-    theString = theString.replace(/,/g, "\\,");
-
-    // theString.replace(/\n/g, "\\n,");
-    // theString.replace(/\r/g, "\\r,");
+    theString = theString.replace(/\n|\r\n/g, "\\n");
 
     return theString;
 }
@@ -72,17 +77,6 @@
     return multiValue.split("\u001A");
 }
 
-function unescapedFromCard(theString) {
-    theString = theString.replace(/\\/g, "\\");
-    theString = theString.replace(/\,/g, ",");
-    theString = theString.replace(/\;/g, ";");
-    theString = theString.replace(/\,/g, ",");
-    // theString.replace(/\\n/g, "\n,");
-    // theString.replace(/\\r/g, "\r,");
-
-    return theString;
-}
-
 /* this method parses a versit directory:
  - normalizing the charset and encodings;
  - returning the lines as hashes filled with the tag, parameters and values
@@ -408,33 +405,7 @@
         props["PreferMailFormat"] = value;
     },
     categories: function(props, parameters, values) {
-        let commaValues = values[0];
-        let newValues = [];
-        if (commaValues.length > 0) {
-            let escaped = false;
-            let currentValue = "";
-            for (let i = 0; i < commaValues.length; i++) {
-                if (escaped) {
-                    currentValue += commaValues[i];
-                    escaped = false;
-                }
-                else {
-                    if (commaValues[i] == "\\") {
-                        escaped = true;
-                    }
-                    else if (commaValues[i] == ",") {
-                        newValues.push(currentValue);
-                        currentValue = "";
-                    }
-                    else {
-                        currentValue += commaValues[i];
-                    }
-                }
-            }
-            newValues.push(currentValue);
-        }
-        props["Categories"] = newValues.join("\u001A");
-        // props["Categories"] = arrayToMultiValue(values);
+        props["Categories"] = values[0].split(",").join("\u001A");
     },
     note: function(props, parameters, values) {
         props["Notes"] = values.join(";");
@@ -496,6 +467,11 @@
         }
     };
 
+    /* Remove address grouping, if any, for known tags */
+    let tagparts = tag.split(".");
+    if ((tagparts.length == 2) && (typeof _insertCardMethods[tagparts[1]] != "undefined"))
+        tag = tagparts[1];
+
     if (typeof _insertCardMethods[tag] != "undefined")
         _insertCardMethods[tag](properties, parameters, values);
     else
@@ -614,8 +590,8 @@
     let lastName = card.getProperty("LastName", "");
     let firstName = card.getProperty("FirstName", "");
     if (lastName.length || firstName.length)
-        vCard += foldedLine("N:" + escapedForCard(lastName)
-                            + ";" + escapedForCard(firstName)) + "\r\n";
+        vCard += foldedLine("N:" + escapedForCardList(lastName)
+                            + ";" + escapedForCardList(firstName)) + "\r\n";
 
     let displayName = card.getProperty("DisplayName", "");
     if (displayName.length)
@@ -629,11 +605,11 @@
 
     let nickName = card.getProperty("NickName", "");
     if (nickName.length)
-        vCard += foldedLine("NICKNAME:" + escapedForCard(nickName)) + "\r\n";
+        vCard += foldedLine("NICKNAME:" + escapedForCardList(nickName)) + "\r\n";
 
     let categories = card.getProperty("Categories", "");
     if (categories.length)
-        vCard += foldedLine("CATEGORIES:" + categories.split("\u001A").join(",")) + "\r\n";
+        vCard += foldedLine("CATEGORIES:" + escapedForCardList(categories.split("\u001A").join(","))) + "\r\n";
 
     let workAddress = card.getProperty("WorkAddress", "");
     let workAddress2 = card.getProperty("WorkAddress2", "");
@@ -643,8 +619,9 @@
     let workCountry = card.getProperty("WorkCountry", "");
     if ((workAddress + workAddress2 + workCity + workState + workZipCode
          + workCountry).length)
-        vCard += foldedLine("ADR;TYPE=work:;" + escapedForCard(workAddress2)
-                            + ";" + escapedForCard(workAddress)
+        vCard += foldedLine("ADR;TYPE=work:" 
+                            + ";" + escapedForCardList(workAddress2)
+                            + ";" + escapedForCardList(workAddress)
                             + ";" + escapedForCard(workCity)
                             + ";" + escapedForCard(workState)
                             + ";" + escapedForCard(workZipCode)
@@ -658,8 +635,9 @@
     let homeCountry = card.getProperty("HomeCountry", "");
     if ((homeAddress + homeAddress2 + homeCity + homeState + homeZipCode
          + homeCountry).length)
-        vCard += foldedLine("ADR;TYPE=home:;" + escapedForCard(homeAddress2)
-                            + ";" + escapedForCard(homeAddress)
+        vCard += foldedLine("ADR;TYPE=home:"
+                            + ";" + escapedForCardList(homeAddress2)
+                            + ";" + escapedForCardList(homeAddress)
                             + ";" + escapedForCard(homeCity)
                             + ";" + escapedForCard(homeState)
                             + ";" + escapedForCard(homeZipCode)
@@ -722,7 +700,7 @@
 
     let jobTitle = card.getProperty("JobTitle", "");
     if (jobTitle.length)
-        vCard += foldedLine("TITLE:" + jobTitle) + "\r\n";
+        vCard += foldedLine("TITLE:" + escapedForCard(jobTitle)) + "\r\n";
 
     let birthYear = card.getProperty("BirthYear", 0);
     let birthMonth = card.getProperty("BirthMonth", 0);
@@ -742,7 +720,7 @@
     let notes = card.getProperty("Notes", "");
     if (notes.length) {
         vCard += foldedLine("NOTE:"
-                            + escapedForCard(notes.replace(/\n/g, "\r\n"))) + "\r\n";
+                            + escapedForCard(notes)) + "\r\n";
     }
 
     let aimScreenName = card.getProperty("_AimScreenName", "");
