summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniko <niko>2012-10-26 12:10:43 (GMT)
committerniko <niko>2012-10-26 12:10:43 (GMT)
commit238dc34ac96a1a1268e2d5e27e07009157920cd2 (patch)
tree093a445feb7e370a0899c0ecd14b79090576e273
parent15b7152f1e238951bb958dca427af4470261d9ee (diff)
downloadsynckolab-238dc34ac96a1a1268e2d5e27e07009157920cd2.tar.gz
fix utf-8 handling and cleaned contact parsing
-rw-r--r--src/chrome/content/synckolab/addressbookTools.js36
-rw-r--r--src/chrome/content/synckolab/tools.js39
-rw-r--r--test/lib/testOverride.js45
-rw-r--r--test/synckolab/parser/kolab2/contactTest.js6
-rw-r--r--test/synckolab/parser/kolab2/json/list.test.json12
-rw-r--r--test/synckolab/parser/kolab2/json/testcontact.json16
-rw-r--r--test/synckolab/parser/kolab2/raw/contactFullTest.eml (renamed from test/synckolab/parser/kolab2/raw/contactFullTest.xml)33
-rw-r--r--test/synckolab/parser/kolab2/raw/contactMinimalTest.eml43
-rw-r--r--test/synckolab/parser/kolab2/raw/contactMinimalTest.xml16
-rw-r--r--test/synckolab/parser/kolab2/raw/list.test.eml6
-rw-r--r--test/synckolab/parser/kolab2/raw/list.test.xml21
-rw-r--r--test/synckolab/parser/kolab2/raw/list.test2.eml (renamed from test/synckolab/parser/kolab2/raw/list.test2.xml)0
-rw-r--r--test/synckolab/parser/kolab2/raw/testcontact.eml (renamed from test/synckolab/parser/kolab2/raw/testcontact.xml)32
-rw-r--r--test/synckolab/parser/kolab3/calendarTest.js1
-rw-r--r--test/synckolab/parser/kolab3/contactTest.js38
-rw-r--r--test/synckolab/parser/kolab3/json/contact.complex.mime.json6
-rw-r--r--test/synckolab/parser/kolab3/xml/contact.complex.mime.xml1
17 files changed, 244 insertions, 107 deletions
diff --git a/src/chrome/content/synckolab/addressbookTools.js b/src/chrome/content/synckolab/addressbookTools.js
index ea6b64d..ba9d560 100644
--- a/src/chrome/content/synckolab/addressbookTools.js
+++ b/src/chrome/content/synckolab/addressbookTools.js
@@ -886,6 +886,10 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
}
// convert to date
tok = synckolab.tools.text.string2DateTime(tok);
+ if (!tok || tok+"" === "Invalid Date") {
+ synckolab.tools.logMessage("Unable to parse birthday: " + cur.getFirstData(), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
+ break;
+ }
this.setCardProperty(card, "BirthYear", tok.getFullYear());
this.setCardProperty(card, "BirthMonth", tok.getMonth()+1); // getMoth starts with jan=0
@@ -913,6 +917,10 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
}
// convert to date
tok = synckolab.tools.text.string2DateTime(tok);
+ if (!tok || tok+"" === "Invalid Date") {
+ synckolab.tools.logMessage("Unable to parse anniversary: " + cur.getFirstData(), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
+ break;
+ }
this.setCardProperty(card, "AnniversaryYear", tok.getFullYear());
this.setCardProperty(card, "AnniversaryMonth", tok.getMonth()+1); // getMoth starts with jan=0
@@ -1002,12 +1010,12 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
// data:image/png;base64,BASE64DATA
types = types.substring(5); // cut away data:
tok = types.indexOf(";"); // search for the mime
- where = synckolab.tools.file.analyzeMimeType(type.substring(0, tok).toLowerCase());
+ where = synckolab.tools.file.analyzeMimeType(types.substring(0, tok).toLowerCase());
// set the type
this.setCardProperty(card, "PhotoType", "inline");
this.setCardProperty(card, "PhotoName", "photo." + where); // generate filename
- where = type.substring(tok);
+ where = types.substring(tok);
if(where.indexOf("base64") !== -1) {
tok = value.indexOf(",");
// get rid of newlines and =
@@ -1057,6 +1065,14 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
this.setCardProperty(card, "Notes", cnotes.replace(/\\n/g, "\n"));
found = true;
break;
+ case "PROFESSION":
+ if (cur.firstChild === null) {
+ break;
+ }
+ this.setCardProperty(card, "Profession", cur.getFirstData());
+ found = true;
+ break;
+
case "DEPARTMENT":
if (cur.firstChild === null) {
break;
@@ -1209,8 +1225,13 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
case "X-CUSTOM": // kolab3
tok = cur.getXmlResult("identifier", "");
value = cur.getXmlResult("value", "");
+ // skip empty value
+ if(value === "") {
+ break;
+ }
switch(tok) {
case "X-AllowRemoteContent": this.setCardProperty(card, "AllowRemoteContent", 'TRUE' === value.toUpperCase()); break;
+ case "X-Profession": this.setCardProperty(card, "Profession", value); break;
case "X-Custom1": this.setCardProperty(card, "Custom1", value); break;
case "X-Custom2": this.setCardProperty(card, "Custom2", value); break;
case "X-Custom3": this.setCardProperty(card, "Custom3", value); break;
@@ -1261,7 +1282,7 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
case "LONGITUDE":
case "ASSISTANT":
case "MANAGER-NAME":
- case "PROFESSION":
+ case "PREFERRED-ADDRESS":
case "SPOUSE-NAME":
case "CHILDREN":
case "GENDER":
@@ -1403,7 +1424,6 @@ synckolab.addressbookTools.list2Kolab3 = function (card, fields) {
}
xml += "</vcard>\n</vcards>\n";
- synckolab.tools.logMessage("list: " + xml, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return xml;
};
@@ -1759,6 +1779,10 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
xml += " <x-custom><identifier>X-Custom4</identifier><value>"+this.getCardProperty(card, "Custom4")+"</value></x-custom>\n";
}
+ if (this.getCardProperty(card, "Profession")) {
+ xml += " <x-custom><identifier>Profession</identifier><value>"+this.getCardProperty(card, "Profession")+"</value></x-custom>\n";
+ }
+
if (this.getCardProperty(card, "AllowRemoteContent")) {
xml += " <x-custom><identifier>X-AllowRemoteContent</identifier><value>true</value></x-custom>\n";
} else {
@@ -1813,7 +1837,8 @@ synckolab.addressbookTools.card2Pojo = function (card, uid, fields) {
"WorkAddress2", "WorkCity", "WorkState", "WorkZipCode", "WorkCountry",
"PhotoName", "PhotoType", "PhotoURI", "Notes", "Department",
"WebPage1", "WebPage2", "WebPage3",
- "AimScreenName", "Custom1", "Custom2", "Custom3", "Custom4", "AllowRemoteContent", "PreferMailFormat"];
+ "AimScreenName", "Custom1", "Custom2", "Custom3", "Custom4", "AllowRemoteContent", "PreferMailFormat",
+ "Profesion"];
var i;
for(i = 0; i < copyFields.length; i++) {
this.setCardProperty(pojo, copyFields[i], this.getCardProperty(card, copyFields[i]));
@@ -2014,6 +2039,7 @@ synckolab.addressbookTools.card2Xml = function (card, fields) {
xml += synckolab.tools.text.nodeWithContent("custom2", this.getCardProperty(card, "Custom2"), false);
xml += synckolab.tools.text.nodeWithContent("custom3", this.getCardProperty(card, "Custom3"), false);
xml += synckolab.tools.text.nodeWithContent("custom4", this.getCardProperty(card, "Custom4"), false);
+ xml += synckolab.tools.text.nodeWithContent("profession", this.getCardProperty(card, "Profession"), false);
if (this.getCardProperty(card, "AllowRemoteContent")) {
xml += synckolab.tools.text.nodeWithContent("allow-remote-content", "true", false);
} else {
diff --git a/src/chrome/content/synckolab/tools.js b/src/chrome/content/synckolab/tools.js
index be1a9b9..5135414 100644
--- a/src/chrome/content/synckolab/tools.js
+++ b/src/chrome/content/synckolab/tools.js
@@ -46,6 +46,18 @@ synckolab.tools = {
logStart: -1,
lastmsg: -1,
+/**
+ * @return a stack trace or an empty string
+ */
+trace: function() {
+ try {
+ throw new Error("myError");
+ }
+ catch(e) {
+ return e.stack;
+ }
+ return "";
+},
/**
* Prints out debug messages to the cosole if the global variable DEBUG_SYNCKOLAB is set to true
* Also prints out performance related stuff
@@ -90,11 +102,10 @@ logMessage: function (msg, level) {
}
// report errors as error
if (clvl === synckolab.global.LOG_ERROR && Components.utils.reportError) {
- var err = new Error("" + msg);
- Components.utils.reportError("" + msg + err.stack);
+ Components.utils.reportError("" + msg + "\nStack Trace: " + this.trace());
} else
if (clvl === synckolab.global.LOG_ERROR) {
- synckolab.global.consoleService.logStringMessage("" + msg + new Error("" + msg).stack);
+ synckolab.global.consoleService.logStringMessage("" + msg + "\nStack Trace: " + this.trace());
} else {
synckolab.global.consoleService.logStringMessage(msg);
}
@@ -189,7 +200,7 @@ equalsObject: function(a, b, skipFields)
{
continue;
}
- synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_INFO);
return false;
}
}
@@ -201,7 +212,7 @@ equalsObject: function(a, b, skipFields)
switch(typeof(a[p])) {
case 'object':
if (!this.equalsObject(a[p], b[p])) {
- synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_INFO);
return false;
}
break;
@@ -212,13 +223,13 @@ equalsObject: function(a, b, skipFields)
break;
}
if (a[p] !== b[p] && Number(a[p]) !== Number(b[p])) {
- synckolab.tools.logMessage("not equals: : " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: : " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_INFO);
return false;
}
}
} else {
if (b[p]) {
- synckolab.tools.logMessage("not equals: " + p + " a: not found b: " + b[p], synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: not found b: " + b[p], synckolab.global.LOG_INFO);
return false;
}
}
@@ -230,7 +241,7 @@ equalsObject: function(a, b, skipFields)
if(skipFields && skipFields[p]) {
continue;
}
- synckolab.tools.logMessage("not equals: " + p + " a: " + (a?a[p]:'is null') + " b: " + b[p], synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: " + (a?a[p]:'is null') + " b: " + b[p], synckolab.global.LOG_INFO);
return false;
}
}
@@ -425,11 +436,11 @@ stripMailHeader: function (skcontent) {
isQP = skcontent.search(/Content-Transfer-Encoding:[ \t\r\n]+quoted-printable/i);
var isBase64 = skcontent.search(/Content-Transfer-Encoding:[ \t\r\n]+base64/i);
- this.logMessage("contentIdx === -1: looks like its encoded: QP=" + isQP + " B64=" + isBase64);
+ this.logMessage("contentIdx === -1: looks like its encoded: QP=" + isQP + " B64=" + isBase64, synckolab.global.LOG_DEBUG);
if (isBase64 !== -1)
{
- this.logMessage("Base64 Decoding message. (Boundary: "+boundary+")", synckolab.global.LOG_INFO);
+ this.logMessage("Base64 Decoding message. (Boundary: "+boundary+")", synckolab.global.LOG_DEBUG);
// get rid of the header
skcontent = skcontent.substring(isBase64, skcontent.length);
startPos = skcontent.indexOf("\r\n\r\n");
@@ -458,7 +469,7 @@ stripMailHeader: function (skcontent) {
// out of memory error... this can be handled :)
if (e.result === Components.results.NS_ERROR_OUT_OF_MEMORY)
{
- skcontent = synckolab.text.base64.decode(skcontent);
+ skcontent = synckolab.tools.text.base64.decode(skcontent);
this.logMessage("decoded base64: " + skcontent, synckolab.global.LOG_DEBUG);
}
@@ -468,6 +479,10 @@ stripMailHeader: function (skcontent) {
return null;
}
}
+ // decode utf8
+ if(skcontent) {
+ skcontent = synckolab.tools.text.utf8.decode(skcontent);
+ }
}
@@ -511,7 +526,7 @@ stripMailHeader: function (skcontent) {
// check if we have to decode quoted printable
if (skcontent.indexOf(" version=3D") !== -1 || skcontent.indexOf("TZID=3D")) // we know from the version (or in case of citadel from the tzid)
{
- this.logMessage("Message is quoted", synckolab.global.LOG_INFO);
+ this.logMessage("Message is quoted", synckolab.global.LOG_DEBUG);
skcontent = synckolab.tools.text.quoted.decode(skcontent);
}
diff --git a/test/lib/testOverride.js b/test/lib/testOverride.js
index 4b0d785..dbf7366 100644
--- a/test/lib/testOverride.js
+++ b/test/lib/testOverride.js
@@ -1,3 +1,13 @@
+synckolab.global = {
+ // log settings
+ LOG_ERROR: 0,
+ LOG_WARNING: 1,
+ LOG_INFO: 2,
+ LOG_DEBUG: 3,
+ LOG_CAL: 4,
+ LOG_AB: 8,
+ LOG_ALL: 12
+};
synckolab.config = {
version: "3.0.0",
@@ -8,26 +18,16 @@ synckolab.config = {
// set this to true to also print timing information
PERFLOG_SYNCKOLAB: true,
- DEBUG_SYNCKOLAB_LEVEL: 15, // global.global.LOG_ALL + global.global.LOG_DEBUG
+ DEBUG_SYNCKOLAB_LEVEL: synckolab.global.LOG_ALL + synckolab.global.LOG_INFO,
//set this to true and on every error there will be a pause so you can check the logs
PAUSE_ON_ERROR: false
};
-synckolab.global = {
- // log settings
- LOG_ERROR: 0,
- LOG_WARNING: 1,
- LOG_INFO: 2,
- LOG_DEBUG: 3,
- LOG_CAL: 4,
- LOG_AB: 8,
- LOG_ALL: 12
-};
-synckolab.global= consoleService = {
+synckolab.global.consoleService = {
logStringMessage: function(msg) {
- print(msg);
+ print(msg);
}
};
@@ -35,6 +35,23 @@ synckolab.tools.parseXml = function(content) {
return new DOMParser().parseFromString(content, "application/xml");
}
-synckolab.tools.logMessage = function (msg) {
+synckolab.tools.logMessage = function(msg, level) {
+ if (!level) {
+ print("NO LEVEL GIVEN: " + synckolab.tools.trace());
+ }
+ var infolvl = synckolab.config.DEBUG_SYNCKOLAB_LEVEL%4;
+ var infostate = synckolab.config.DEBUG_SYNCKOLAB_LEVEL - infolvl;
+ var clvl = level%4;
+ var cstate = level - clvl;
+
+ // check if we are talking about the same loglevel: ERROR|WARN|INFO|DEBUG
+ if (clvl > infolvl) {
+ return;
+ }
+
+ if (clvl === synckolab.global.LOG_ERROR) {
+ print("" + msg + "\nStack Trace: " + this.trace());
+ }
+
print(msg);
} \ No newline at end of file
diff --git a/test/synckolab/parser/kolab2/contactTest.js b/test/synckolab/parser/kolab2/contactTest.js
index 2ae83f1..99608a1 100644
--- a/test/synckolab/parser/kolab2/contactTest.js
+++ b/test/synckolab/parser/kolab2/contactTest.js
@@ -13,13 +13,15 @@ load("test/lib/testOverride.js");
test("skolab2 ynckolab.addressbookTools.parseMessageContent", function(){
equal(null, synckolab.addressbookTools.parseMessageContent(null), "parsing a null message");
- var testFiles = ["contactMinimalTest", "contactFullTest", "list.test", "list.test2"];
+ var testFiles = ["testcontact", "contactMinimalTest", "contactFullTest", "list.test", "list.test2"];
var content, entry, jsonEntry;
for(var i = 0; i < testFiles.length; i++) {
var src = testFiles[i];
+ print("INFO: KOLAB 2 TESTING CONTACT: " + src +"\n");
- content = readFile("test/synckolab/parser/kolab2/raw/"+src+".xml");
+ content = readFile("test/synckolab/parser/kolab2/raw/"+src+".eml");
+ content = synckolab.tools.stripMailHeader(content);
entry = synckolab.addressbookTools.parseMessageContent(content);
content = readFile("test/synckolab/parser/kolab2/json/"+src+".json");
jsonEntry = JSON.parse(content);
diff --git a/test/synckolab/parser/kolab2/json/list.test.json b/test/synckolab/parser/kolab2/json/list.test.json
index 8e1e3b6..1de61e9 100644
--- a/test/synckolab/parser/kolab2/json/list.test.json
+++ b/test/synckolab/parser/kolab2/json/list.test.json
@@ -2,20 +2,20 @@
"synckolab": "3.0.0",
"type": "maillist",
"isMailList": true,
- "ts": 1349908157804,
+ "ts": 1351253178012,
+ "UUID": "list_name",
"DisplayName": "list-name",
"Notes": "list-description",
"NickName": "list-nickname",
- "UUID": "SomeRandomUUID",
"contacts": [
{
"synckolab": "3.0.0",
"listMember": true,
"type": "contact",
"isMailList": false,
- "ts": 1349908157831,
+ "ts": 1351253178057,
"DisplayName": "testöä lastname",
- "PrimaryEmail": "weird@email.com",
+ "PrimaryEmail": "email@mail.com",
"UUID": "urn:uuid:pas-id-1D84CEA337CD1878"
},
{
@@ -23,11 +23,11 @@
"listMember": true,
"type": "contact",
"isMailList": false,
- "ts": 1349908157832,
+ "ts": 1351253178058,
"DisplayName": "cont2#öüä&$",
"PrimaryEmail": "weird@email.com",
"UUID": "urn:uuid:pas-id-A4E937D838A897AD"
}
],
"sha1": "8d2e5e0088530d5fbe9f6acc40a5e3eb2c094ec7"
-} \ No newline at end of file
+} \ No newline at end of file
diff --git a/test/synckolab/parser/kolab2/json/testcontact.json b/test/synckolab/parser/kolab2/json/testcontact.json
index a94b85d..1bc576b 100644
--- a/test/synckolab/parser/kolab2/json/testcontact.json
+++ b/test/synckolab/parser/kolab2/json/testcontact.json
@@ -4,28 +4,17 @@
"isMailList": false,
"ts": 1349214053542,
"UUID": "uid",
- "creation-date": "2004-05-04T15:00:00Z",
"FirstName": "(string, default empty)",
"LastName": "(string, default empty)",
"DisplayName": "(string, default empty)",
- "free-busy-url": "(string, default empty)",
"Company": "(string, default empty)",
"WebPage1": "(string, default empty)",
"AimScreenName": "(string, default empty)",
"Department": "(string, default empty)",
- "office-location": "(string, default empty)",
- "profession": "(string, default empty)",
"JobTitle": "(string, default empty)",
- "manager-name": "(string, default empty)",
- "assistant": "(string, default empty)",
"NickName": "(string, default empty)",
- "spouse-name": "(string, default empty)",
- "BirthYear": "(date, no default)",
- "AnniversaryYear": "(date, no default)",
"PhotoName": "(string(attachment filename), default empty)",
- "children": "(string, default empty)",
- "gender": "(string, default empty)",
- "language": "(string, default empty)",
+ "Profession": "(string, default empty)",
"CellularNumber": "(string, default empty)",
"PrimaryEmail": "(string, default empty)",
"HomeAddress": "(string, default empty)",
@@ -34,8 +23,5 @@
"HomeState": "(string, default empty)",
"HomeZipCode": "(string, default empty)",
"HomeCountry": "(string, default empty)",
- "preferred-address": "(string, default none)",
- "latitude": "3.23",
- "longitude": "5.222",
"sha1": "9bd2adac4fdeb9e44eb5c2f05d2a5458a9170703"
} \ No newline at end of file
diff --git a/test/synckolab/parser/kolab2/raw/contactFullTest.xml b/test/synckolab/parser/kolab2/raw/contactFullTest.eml
index b0eaa88..bbfabdf 100644
--- a/test/synckolab/parser/kolab2/raw/contactFullTest.xml
+++ b/test/synckolab/parser/kolab2/raw/contactFullTest.eml
@@ -1,5 +1,31 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<contact version="1.0" >
+Date: Fri, 27 Apr 2012 02:25:38 +0200
+X-Kolab-Type: application/x-vnd.kolab.contact
+X-Kolab-Mime-Version: 3.0
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart38186565.1WqI9LYOEs"
+Subject: Huu5X7hfYy
+From: Displayname <first@email.org>
+MIME-Version: 1.0
+
+
+--nextPart38186565.1WqI9LYOEs
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7Bit
+
+This is a Kolab Groupware object.
+To view this object you will need an email client that can understand the Kolab Groupware format.
+For a list of such email clients please visit
+http://www.kolab.org/kolab2-clients.html
+
+--Boundary-00=6988F02CCC809628
+Content-Type: application/x-vnd.kolab.contact;
+ name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment;
+ filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+<contact version=3D"1.0" >
<product-id>SyncKolab, Kolab resource</product-id>
<uid>pas-id-1D84CEA337CD1878</uid>
<last-modification-date>2012-07-04T10:45:33Z</last-modification-date>
@@ -38,7 +64,7 @@ note with öäü!</body>
<type>page</type>
<number>01-page</number>
</phone>
- <email type="primary">
+ <email type=3D"primary">
<display-name>testöä lastname</display-name>
<smtp-address>email@mail.com</smtp-address>
</email>
@@ -69,3 +95,4 @@ note with öäü!</body>
<custom3>cust3</custom3>
<allow-remote-content>true</allow-remote-content>
</contact>
+--Boundary-00=6988F02CCC809628-- \ No newline at end of file
diff --git a/test/synckolab/parser/kolab2/raw/contactMinimalTest.eml b/test/synckolab/parser/kolab2/raw/contactMinimalTest.eml
new file mode 100644
index 0000000..675157d
--- /dev/null
+++ b/test/synckolab/parser/kolab2/raw/contactMinimalTest.eml
@@ -0,0 +1,43 @@
+Date: Fri, 27 Apr 2012 02:25:38 +0200
+X-Kolab-Type: application/x-vnd.kolab.contact
+X-Kolab-Mime-Version: 3.0
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart38186565.1WqI9LYOEs"
+Subject: Huu5X7hfYy
+From: Displayname <first@email.org>
+MIME-Version: 1.0
+
+
+--nextPart38186565.1WqI9LYOEs
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7Bit
+
+This is a Kolab Groupware object.
+To view this object you will need an email client that can understand the Kolab Groupware format.
+For a list of such email clients please visit
+http://www.kolab.org/kolab2-clients.html
+
+--Boundary-00=6988F02CCC809628
+Content-Type: application/x-vnd.kolab.contact;
+ name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment;
+ filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+<contact version=3D"1.0" >
+ <product-id>SyncKolab, Kolab resource</product-id>
+ <uid>sk-vc-C18A6B3AE0CD9EDC</uid>
+ <last-modification-date>2012-07-04T10:45:33Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <name>
+ <given-name>Test</given-name>
+ <last-name>LastName</last-name>
+ <full-name>Test Lastname</full-name>
+ </name>
+ <email type=3D"primary">
+ <smtp-address>email@test.com</smtp-address>
+ </email>
+ <allow-remote-content>true</allow-remote-content>
+</contact>
+--Boundary-00=6988F02CCC809628-- \ No newline at end of file
diff --git a/test/synckolab/parser/kolab2/raw/contactMinimalTest.xml b/test/synckolab/parser/kolab2/raw/contactMinimalTest.xml
deleted file mode 100644
index 3e1221a..0000000
--- a/test/synckolab/parser/kolab2/raw/contactMinimalTest.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<contact version="1.0" >
- <product-id>SyncKolab, Kolab resource</product-id>
- <uid>sk-vc-C18A6B3AE0CD9EDC</uid>
- <last-modification-date>2012-07-04T10:45:33Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <name>
- <given-name>Test</given-name>
- <last-name>LastName</last-name>
- <full-name>Test Lastname</full-name>
- </name>
- <email type="primary">
- <smtp-address>email@test.com</smtp-address>
- </email>
- <allow-remote-content>true</allow-remote-content>
-</contact>
diff --git a/test/synckolab/parser/kolab2/raw/list.test.eml b/test/synckolab/parser/kolab2/raw/list.test.eml
index 9963cd3..8d09f34 100644
--- a/test/synckolab/parser/kolab2/raw/list.test.eml
+++ b/test/synckolab/parser/kolab2/raw/list.test.eml
@@ -1,4 +1,4 @@
-From: niko.berger@corinis.com
+From: owner@no.tld
Reply-To:
Bcc:
To: synckolab@no.tld
@@ -22,8 +22,8 @@ Name: list-name
Notes: list-description
Members:
-test lastname <email@mail.com>
-cont2#&$ <weird@email.com>
+test�� lastname <email@mail.com>
+cont2#���&$ <weird@email.com>
---
Notice:
diff --git a/test/synckolab/parser/kolab2/raw/list.test.xml b/test/synckolab/parser/kolab2/raw/list.test.xml
deleted file mode 100644
index 9f07b00..0000000
--- a/test/synckolab/parser/kolab2/raw/list.test.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<distribution-list version="1.0" >
- <product-id>SyncKolab, Kolab resource</product-id>
- <uid>list_name</uid>
- <creation-date>20121017T214612Z</creation-date>
- <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <name>list-name</name>
- <body>list-description</body>
- <nickname>list-nickname</nickname>
- <member>
- <display-name>testöä lastname</display-name>
- <smtp-address>weird@email.com</smtp-address>
- <uid>urn:uuid:pas-id-1D84CEA337CD1878</uid>
- </member>
- <member>
- <display-name>cont2#öüä&amp;$</display-name>
- <smtp-address>weird@email.com</smtp-address>
- <uid>urn:uuid:pas-id-A4E937D838A897AD</uid>
- </member>
-</distribution-list>
diff --git a/test/synckolab/parser/kolab2/raw/list.test2.xml b/test/synckolab/parser/kolab2/raw/list.test2.eml
index dfb734d..dfb734d 100644
--- a/test/synckolab/parser/kolab2/raw/list.test2.xml
+++ b/test/synckolab/parser/kolab2/raw/list.test2.eml
diff --git a/test/synckolab/parser/kolab2/raw/testcontact.xml b/test/synckolab/parser/kolab2/raw/testcontact.eml
index 95ca60c..c3343c7 100644
--- a/test/synckolab/parser/kolab2/raw/testcontact.xml
+++ b/test/synckolab/parser/kolab2/raw/testcontact.eml
@@ -1,5 +1,32 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<contact version="3.0dev1" xmlns="http://kolab.org">
+From: owner@no.tld
+Reply-To:
+Bcc:
+To: synckolab@no.tld
+Subject: list_name
+Date: Thu, 11 Oct 2012 00:20:52 +0200
+Content-Type: Multipart/Mixed;boundary="Boundary-00=173882C61DEE82C7"
+User-Agent: SyncKolab 2.9.0
+X-Kolab-Type: application/x-vnd.kolab.contact.distlist
+
+--Boundary-00=173882C61DEE82C7
+Content-Type: Text/Plain;
+ charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+This is a Kolab Groupware object.
+To view this object you will need an email client that can understand the Kolab Groupware format.
+For a list of such email clients please visit
+http://www.kolab.org/kolab2-clients.html
+
+--Boundary-00=173882C61DEE82C7
+Content-Type: application/x-vnd.kolab.contact;
+ name="kolab.xml"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment;
+ filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+<contact version=3D"3.0dev1" xmlns=3D"http://kolab.org">
<!-- Common fields -->
<uid>uid</uid>
<body></body>
@@ -58,3 +85,4 @@
<longitude>5.222</longitude>
</contact>
+--Boundary-00=173882C61DEE82C7-- \ No newline at end of file
diff --git a/test/synckolab/parser/kolab3/calendarTest.js b/test/synckolab/parser/kolab3/calendarTest.js
index 7e9f38d..e3c912b 100644
--- a/test/synckolab/parser/kolab3/calendarTest.js
+++ b/test/synckolab/parser/kolab3/calendarTest.js
@@ -18,6 +18,7 @@ test("kolab3 synckolab.addressbookTools.parseMessageContent", function(){
for(var i = 0; i < testFiles.length; i++) {
var src = testFiles[i];
+ print("INFO: KOLAB 3 TESTING - EVENT: " + src +"\n")
content = readFile("test/synckolab/parser/kolab3/raw/"+src);
content = synckolab.tools.stripMailHeader(content);
diff --git a/test/synckolab/parser/kolab3/contactTest.js b/test/synckolab/parser/kolab3/contactTest.js
index b697529..3a66a08 100644
--- a/test/synckolab/parser/kolab3/contactTest.js
+++ b/test/synckolab/parser/kolab3/contactTest.js
@@ -18,16 +18,13 @@ test("kolab3 synckolab.addressbookTools.parseMessageContent", function(){
for(var i = 0; i < testFiles.length; i++) {
var src = testFiles[i];
-
+ print("INFO: KOLAB 3 TESTING - CONTACT: " + src +"\n")
content = readFile("test/synckolab/parser/kolab3/raw/"+src);
content = synckolab.tools.stripMailHeader(content);
entry = synckolab.addressbookTools.parseMessageContent(content);
- if(entry.isMailList) {
- print(entry.toSource());
- }
content = readFile("test/synckolab/parser/kolab3/json/"+src+".json");
jsonEntry = JSON.parse(content);
- equal(synckolab.tools.equalsObject(entry, jsonEntry), true, src);
+ equal(synckolab.tools.equalsObject(entry, jsonEntry), true, "Json object compare: " + src);
// json -> kolab 3 xml
if(entry.type === "maillist") {
@@ -39,10 +36,39 @@ test("kolab3 synckolab.addressbookTools.parseMessageContent", function(){
if (xmlcontent.replace(/[\n\r\t ]/g, "").length !== content.replace(/[\n\r\t ]/g, "").length) {
equal(xmlcontent.replace(/[\n\r\t ]/g, ""), content.replace(/[\n\r\t ]/g, ""), src);
var diff = diffString(xmlcontent, content);
- print("DIFF FOUND:"+ xmlcontent.replace(/[\n\r\t ]/g, "").length + " vs. "+ content.replace(/[\n\r\t ]/g, "").length +"\n" + diff);
+ print("ERROR: DIFF FOUND:"+ xmlcontent.replace(/[\n\r\t ]/g, "").length + " vs. "+ content.replace(/[\n\r\t ]/g, "").length +"\n" + diff);
}
}
});
+
+/*
+var testFiles = ["contact.complex.mime"];
+for(var i = 0; i < testFiles.length; i++) {
+ var src = testFiles[i];
+ print("KOLAB 3 TESTING: " + src +"\n============")
+ content = readFile("test/synckolab/parser/kolab3/raw/"+src);
+ content = synckolab.tools.stripMailHeader(content);
+ entry = synckolab.addressbookTools.parseMessageContent(content);
+ if(entry.isMailList) {
+ print(entry.toSource());
+ }
+ content = readFile("test/synckolab/parser/kolab3/json/"+src+".json");
+ jsonEntry = JSON.parse(content);
+
+ // json -> kolab 3 xml
+ if(entry.type === "maillist") {
+ content = synckolab.addressbookTools.list2Kolab3(entry);
+ } else {
+ content = synckolab.addressbookTools.card2Kolab3(entry);
+ }
+ xmlcontent = readFile("test/synckolab/parser/kolab3/xml/"+src + ".xml");
+ if (xmlcontent.replace(/[\n\r\t ]/g, "").length !== content.replace(/[\n\r\t ]/g, "").length) {
+ equal(xmlcontent.replace(/[\n\r\t ]/g, ""), content.replace(/[\n\r\t ]/g, ""), src);
+ var diff = diffString(xmlcontent, content);
+ print("DIFF FOUND:"+ xmlcontent.replace(/[\n\r\t ]/g, "").length + " vs. "+ content.replace(/[\n\r\t ]/g, "").length +"\n" + diff);
+ }
+}
+*/
/*
var testFiles = ["list.test1.eml"];
diff --git a/test/synckolab/parser/kolab3/json/contact.complex.mime.json b/test/synckolab/parser/kolab3/json/contact.complex.mime.json
index 9745af3..c2cb6d0 100644
--- a/test/synckolab/parser/kolab3/json/contact.complex.mime.json
+++ b/test/synckolab/parser/kolab3/json/contact.complex.mime.json
@@ -9,8 +9,10 @@
"LastName": "Firstname",
"Notes": "Notes",
"JobTitle": "Title",
- "PhotoType": "inline:image/png",
- "PhotoData": "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOTQAADpwB3vacVwAABAVJREFUeJztncFrFGcYxt/szLrJmk2yWTeojQktQluiqNFeKglSQmsOHhRyUApKPbeHQC8taKl4E0Hw4sGToAcvgojVQCg0B+2ph0DprTlYs7SQsNlkdzKzmf4DzxvYsCRP9Pkdn5n53iG/fPDy7TczZkIIIYQQov107PQNtI0vrR/mOfveveap/eAcSXeqRsYdSOwIEkKGhJAhIWRICBkSQsbua3u/slEUj346OoPyUrGEW1Uzm5mfycMDNRtB8ciHIy9RXswXi16NuYU5XOOx1VGsGUKGhJAhIWRICBkSQka40zfgcs6uoHjis4l7KB8fG8+ifPa3Wb9GZJdRPHZq7A7KTx45CWu8/uO1X6NFNEPIkBAyJIQMCSFDQsjYni4rxWtmnVOdsGMyM5s8PfkNyocPDwcor1QrcJwoiNzbOvvF2bsoL5fKsMZidRGOU7OaW6NVNEPIkBAyJIQMCSFDQshob5flbCTr/br3BcrPjJ854Q2V78/DTudt9S08P7YY5uXhslfC4jjGNdZwjaSewHwtXHNrtIpmCBkSQoaEkCEhZEgIGRJCxtba3vN4s1q5NADb2+MfHYMbyRqZBmw7zcxqq3jBLg5xe5tkcEu6buteCUsSfE0cOzUifH4jbLg1WkUzhAwJIUNCyJAQMiSEDL/LumQXvENDhaFHKB/sG4QbyZaiJfgTblLDXYuZWZzHnc56irum9SzOkw6/RtOaOE9xnjTxWJmwff/XmiFkSAgZEkKGhJAhIWT4XVYQuOtMS7Vl+J6ON3+/gedv7NvAA5X8G0uL+HUj5j1eCfu7TfLNjjmlzdlz19XEz3VuBc0QMiSEDAkhQ0LIkBAy/C7rQfOxd2jl6toCygufFJ6jPGlEPSiv5+p+/b1OXnByr/varAHyuinv6QLn/CByG9KW0QwhQ0LIkBAyJIQMCSFDQsjY2ka5+8nvKF6ZXv4Y5YWBnl9R3pfthOebmS1nl/C9dToXOO1wrj/nlbAocVYLvXZ4FcdBs32P2WiGkCEhZEgIGRJChoSQ0d6ncG/bfyheSatHUd71c/dDb6gDuQ+mUL6Y/gNX8tIUt0Z9/7qv7bVKXME74jIbeLXQ+SU6zKjLemeREDIkhAwJIUNCyNieN8p14NWhutUuepdEPzVeofxQbugWyivVRa/78r8A8Zf9CPOBzA0U70lC+PcK0qBtX5nQDCFDQsiQEDIkhAwJIWP3fYPqevg5ig8ePPALynu7e72tdfbnk3m8je54eArF+8v7n6G8mOnza7xwaugbVLsDCSFDQsiQEDIkhAwJIWP3tb0eNw2+MTnoyl7zLmlOx985h/DvwV6Nnk1qfNtaDc0QMiSEDAkhQ0LIkBAhhBBCCPEe8D+b5dDLeP4TXAAAAABJRU5ErkJggg"
+ "Profession": "Profession",
+ "PhotoName": "photo.png",
+ "PhotoType": "inline",
+ "PhotoData": "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOTQAADpwB3vacVwAABAVJREFUeJztncFrFGcYxt/szLrJmk2yWTeojQktQluiqNFeKglSQmsOHhRyUApKPbeHQC8taKl4E0Hw4sGToAcvgojVQCg0B+2ph0DprTlYs7SQsNlkdzKzmf4DzxvYsCRP9Pkdn5n53iG/fPDy7TczZkIIIYQQov107PQNtI0vrR/mOfveveap/eAcSXeqRsYdSOwIEkKGhJAhIWRICBkSQsbua3u/slEUj346OoPyUrGEW1Uzm5mfycMDNRtB8ciHIy9RXswXi16NuYU5XOOx1VGsGUKGhJAhIWRICBkSQka40zfgcs6uoHjis4l7KB8fG8+ifPa3Wb9GZJdRPHZq7A7KTx45CWu8/uO1X6NFNEPIkBAyJIQMCSFDQsjYni4rxWtmnVOdsGMyM5s8PfkNyocPDwcor1QrcJwoiNzbOvvF2bsoL5fKsMZidRGOU7OaW6NVNEPIkBAyJIQMCSFDQshob5flbCTr/br3BcrPjJ854Q2V78/DTudt9S08P7YY5uXhslfC4jjGNdZwjaSewHwtXHNrtIpmCBkSQoaEkCEhZEgIGRJCxtba3vN4s1q5NADb2+MfHYMbyRqZBmw7zcxqq3jBLg5xe5tkcEu6buteCUsSfE0cOzUifH4jbLg1WkUzhAwJIUNCyJAQMiSEDL/LumQXvENDhaFHKB/sG4QbyZaiJfgTblLDXYuZWZzHnc56irum9SzOkw6/RtOaOE9xnjTxWJmwff/XmiFkSAgZEkKGhJAhIWT4XVYQuOtMS7Vl+J6ON3+/gedv7NvAA5X8G0uL+HUj5j1eCfu7TfLNjjmlzdlz19XEz3VuBc0QMiSEDAkhQ0LIkBAy/C7rQfOxd2jl6toCygufFJ6jPGlEPSiv5+p+/b1OXnByr/varAHyuinv6QLn/CByG9KW0QwhQ0LIkBAyJIQMCSFDQsjY2ka5+8nvKF6ZXv4Y5YWBnl9R3pfthOebmS1nl/C9dToXOO1wrj/nlbAocVYLvXZ4FcdBs32P2WiGkCEhZEgIGRJChoSQ0d6ncG/bfyheSatHUd71c/dDb6gDuQ+mUL6Y/gNX8tIUt0Z9/7qv7bVKXME74jIbeLXQ+SU6zKjLemeREDIkhAwJIUNCyNieN8p14NWhutUuepdEPzVeofxQbugWyivVRa/78r8A8Zf9CPOBzA0U70lC+PcK0qBtX5nQDCFDQsiQEDIkhAwJIWP3fYPqevg5ig8ePPALynu7e72tdfbnk3m8je54eArF+8v7n6G8mOnza7xwaugbVLsDCSFDQsiQEDIkhAwJIWP3tb0eNw2+MTnoyl7zLmlOx985h/DvwV6Nnk1qfNtaDc0QMiSEDAkhQ0LIkBAhhBBCCPEe8D+b5dDLeP4TXAAAAABJRU5ErkJggg",
"WebPage1": "www.homepage.org",
"WebPage2": "www.blog.test",
"HomeAddress": "Home Street",
diff --git a/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml b/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml
index d6a1683..4eab87d 100644
--- a/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml
+++ b/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml
@@ -76,6 +76,7 @@
<email>
<text>second@email.org</text>
</email>
+ <x-custom><identifier>Profession</identifier><value>Profession</value></x-custom>
<x-custom><identifier>X-AllowRemoteContent</identifier><value>true</value></x-custom>
</vcard>
</vcards> \ No newline at end of file