summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniko <niko>2012-10-26 12:35:15 (GMT)
committerniko <niko>2012-10-26 12:35:15 (GMT)
commitca36877b242ddafe173e348bfbf7da095d034009 (patch)
treeebeac3e2551dcdcf1276158163c062b132320509
parent238dc34ac96a1a1268e2d5e27e07009157920cd2 (diff)
downloadsynckolab-ca36877b242ddafe173e348bfbf7da095d034009.tar.gz
kolab2 image attachment
-rw-r--r--src/chrome/content/synckolab/addressbookTools.js5
-rw-r--r--src/chrome/content/synckolab/tools.js2
-rw-r--r--test/synckolab/parser/kolab2/contactTest.js2
-rw-r--r--test/synckolab/parser/kolab2/json/test-image.json21
-rw-r--r--test/synckolab/parser/kolab2/raw/test-image.eml75
5 files changed, 104 insertions, 1 deletions
diff --git a/src/chrome/content/synckolab/addressbookTools.js b/src/chrome/content/synckolab/addressbookTools.js
index ba9d560..c7443d8 100644
--- a/src/chrome/content/synckolab/addressbookTools.js
+++ b/src/chrome/content/synckolab/addressbookTools.js
@@ -1044,6 +1044,11 @@ synckolab.addressbookTools.xml2Card = function (xml, card, attachment) {
if (cur.firstChild === null) {
break;
}
+ // we might already have an attached image.. then we can ignore this
+ if(this.getCardProperty(card, "PhotoType") === "inline") {
+ break;
+ }
+
var uri = cur.getFirstData();
// check for local
if (uri.indexOf("file") === 0) {
diff --git a/src/chrome/content/synckolab/tools.js b/src/chrome/content/synckolab/tools.js
index 5135414..d4c4e9c 100644
--- a/src/chrome/content/synckolab/tools.js
+++ b/src/chrome/content/synckolab/tools.js
@@ -371,6 +371,8 @@ stripMailHeader: function (skcontent) {
if (idx !== -1) {
imgC = imgC.substring(0, idx);
}
+ // get rid of windows encoding
+ imgC = imgC.replace(/\r/g, "");
// get the image data (make sure to remove \n and whitespace
idx = imgC.indexOf('\n\n');
diff --git a/test/synckolab/parser/kolab2/contactTest.js b/test/synckolab/parser/kolab2/contactTest.js
index 99608a1..c81ca20 100644
--- a/test/synckolab/parser/kolab2/contactTest.js
+++ b/test/synckolab/parser/kolab2/contactTest.js
@@ -13,7 +13,7 @@ load("test/lib/testOverride.js");
test("skolab2 ynckolab.addressbookTools.parseMessageContent", function(){
equal(null, synckolab.addressbookTools.parseMessageContent(null), "parsing a null message");
- var testFiles = ["testcontact", "contactMinimalTest", "contactFullTest", "list.test", "list.test2"];
+ var testFiles = ["test-image", "testcontact", "contactMinimalTest", "contactFullTest", "list.test", "list.test2"];
var content, entry, jsonEntry;
for(var i = 0; i < testFiles.length; i++) {
diff --git a/test/synckolab/parser/kolab2/json/test-image.json b/test/synckolab/parser/kolab2/json/test-image.json
new file mode 100644
index 0000000..3ce35ea
--- /dev/null
+++ b/test/synckolab/parser/kolab2/json/test-image.json
@@ -0,0 +1,21 @@
+{
+ "synckolab": "3.0.0",
+ "type": "contact",
+ "isMailList": false,
+ "ts": 1351254809554,
+ "PhotoName": "8028141781098217.jpg",
+ "PhotoType": "inline",
+ "PhotoData": "/9j/4AAQSkZJRgABAQEASABIAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCAAYABwDAREAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAABwQFBgj/xAAZAQEAAwEBAAAAAAAAAAAAAAAEAgMFAAH/2gAMAwEAAhADEAAAAegj2mZD2N61phzUd1WPFn26iLoyIwsycPJ3SUWl/8QAHBAAAwEAAgMAAAAAAAAAAAAAAwQFAgABBhIT/9oACAEBAAEFArVcM0LNvDu5OCtZX32QPls0FzM0q6wCPFC1OL9k67tBZ0lv20taLyKxRyh//8QAIhEAAgICAQMFAAAAAAAAAAAAAQIDEQAEEgUTIRAxMkJh/9oACAEDAQE/AYxbe14ep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ced by a software engineer.",
+ "FirstName": "First",
+ "LastName": "Name",
+ "DisplayName": "First Name",
+ "Company": "myOrg",
+ "JobTitle": "Attorney",
+ "NickName": "Name, First",
+ "PrimaryEmail": "name@yahoo.com",
+ "PreferMailFormat": 2,
+ "AllowRemoteContent": true,
+ "sha1": "c4522c8b1a011a75fb702d9c96a9c4929582bfa4"
+} \ No newline at end of file
diff --git a/test/synckolab/parser/kolab2/raw/test-image.eml b/test/synckolab/parser/kolab2/raw/test-image.eml
new file mode 100644
index 0000000..f88595e
--- /dev/null
+++ b/test/synckolab/parser/kolab2/raw/test-image.eml
@@ -0,0 +1,75 @@
+From: test@no.tld
+Reply-To:
+Bcc:
+To: synckolab@no.tld
+Subject: sk-vc-231B43ABC83388D3
+Date: Fri, 23 Mar 2012 15:54:40 +0100
+Content-Type: Multipart/Mixed;boundary="Boundary-00=A7871481E7CA1022"
+User-Agent: SyncKolab 2.0.0
+X-Kolab-Type: application/x-vnd.kolab.contact
+
+--Boundary-00=A7871481E7CA1022
+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=A7871481E7CA1022
+Content-Type: application/x-vnd.kolab.contact;
+ name="kolab.xml"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment;
+ filename="kolab.xml"
+
+PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxjb250YWN0IHZlcnNpb249IjEu
+MCIgPg0KIDxwcm9kdWN0LWlkPlN5bmNLb2xhYiwgS29sYWIgcmVzb3VyY2U8L3Byb2R1Y3QtaWQ+DQog
+PHVpZD5zay12Yy0yMzFCNDNBQkU4MzM4OEQzPC91aWQ+DQogPGxhc3QtbW9kaWZpY2F0aW9uLWRhdGU+
+MTk3MC0wMS0wMVQwMDowMDowMFo8L2xhc3Qtb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