[GH-ISSUE #182] iCloud CardDAV vcf file injecting crlf on photo URL causing a 401 error in logs #647

Closed
opened 2026-03-01 17:40:38 +03:00 by kerem · 7 comments
Owner

Originally created by @iamGavinJ on GitHub (Dec 7, 2016).
Original GitHub issue: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/182

Contact photos aren't being downloaded from iCloud because the vcf file returned has a carriage-return/line-feed in the photo URL after /WBS.

e.g.
PHOTO;TYPE=JPEG;VALUE=uri:https://p02-contacts.icloud.com:443/<MY ID>/wbs /015d400012d0217002d3372af883ca28f0014f5851

The mapping warning report show the following .NET exception
Could not add picture for contact. : System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.Implementation.Contacts.ContactEntityMapper.&lt;MapPhoto2To1&gt;d__20.MoveNext()

Originally created by @iamGavinJ on GitHub (Dec 7, 2016). Original GitHub issue: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/182 Contact photos aren't being downloaded from iCloud because the vcf file returned has a carriage-return/line-feed in the photo URL after `/WBS`. e.g. `PHOTO;TYPE=JPEG;VALUE=uri:https://p02-contacts.icloud.com:443/<MY ID>/wbs /015d400012d0217002d3372af883ca28f0014f5851` The mapping warning report show the following .NET exception ` Could not add picture for contact. : System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CalDavSynchronizer.Implementation.Contacts.ContactEntityMapper.&lt;MapPhoto2To1&gt;d__20.MoveNext() `
kerem closed this issue 2026-03-01 17:40:38 +03:00
Author
Owner

@aluxnimm commented on GitHub (Dec 7, 2016):

Never tested iCloud with contact photos.
The problem is not the cr/lf in the photo attribute but the missing authentication.
When trying the url in the browser, it complains about missing
X-APPLE-WEBAUTH-TOKEN

We would need to fetch that somehow especially for icloud similar to
https://codedump.io/share/OGoCdrXWqeKu/1/get-icloud-contact-list-in-c

<!-- gh-comment-id:265569758 --> @aluxnimm commented on GitHub (Dec 7, 2016): Never tested iCloud with contact photos. The problem is not the cr/lf in the photo attribute but the missing authentication. When trying the url in the browser, it complains about missing X-APPLE-WEBAUTH-TOKEN We would need to fetch that somehow especially for icloud similar to https://codedump.io/share/OGoCdrXWqeKu/1/get-icloud-contact-list-in-c
Author
Owner

@iamGavinJ commented on GitHub (Dec 8, 2016):

Ah, it must have been using cached credentials/cookie because I pasted the link into a browser and it pulled back the image ok.

<!-- gh-comment-id:265734456 --> @iamGavinJ commented on GitHub (Dec 8, 2016): Ah, it must have been using cached credentials/cookie because I pasted the link into a browser and it pulled back the image ok.
Author
Owner

@VincentvgNn commented on GitHub (May 8, 2017):

Hi,
Even if you have no Apple devices you can easily setup a free iCloud account for testing.
I tried the OpenProtocols Connector with iCloud and that works fine for syncing pictures. Unfortunately I could not get that connector working for fruux and the menu is by far not that versatile.
It would be an advantage if the Outlook CalDav Synchronizer could manage picture links from iCloud and that the iCloud logo could be added to the optional synchronization profiles.

<!-- gh-comment-id:299841109 --> @VincentvgNn commented on GitHub (May 8, 2017): Hi, Even if you have no Apple devices you can easily setup a free iCloud account for testing. I tried the OpenProtocols Connector with iCloud and that works fine for syncing pictures. Unfortunately I could not get that connector working for fruux and the menu is by far not that versatile. It would be an advantage if the Outlook CalDav Synchronizer could manage picture links from iCloud and that the iCloud logo could be added to the optional synchronization profiles.
Author
Owner

@aluxnimm commented on GitHub (Sep 12, 2017):

Support for iCloud contact profiles with working picture sync and even sync of Outlook distribution lists to iCloud contact groups implemented in 2.24.0.

<!-- gh-comment-id:328983139 --> @aluxnimm commented on GitHub (Sep 12, 2017): Support for iCloud contact profiles with working picture sync and even sync of Outlook distribution lists to iCloud contact groups implemented in 2.24.0.
Author
Owner

@iamGavinJ commented on GitHub (Sep 13, 2017):

@aluxnimm works fantastically!!! Thank you so much. Awesome work.

<!-- gh-comment-id:329169128 --> @iamGavinJ commented on GitHub (Sep 13, 2017): @aluxnimm works fantastically!!! Thank you so much. Awesome work.
Author
Owner

@arpena commented on GitHub (Sep 20, 2017):

Doesn't work for me. There is some preference that I have to change?

<!-- gh-comment-id:330885731 --> @arpena commented on GitHub (Sep 20, 2017): Doesn't work for me. There is some preference that I have to change?
Author
Owner

@aluxnimm commented on GitHub (Sep 20, 2017):

Yes this is disabled by default. Advanced settings, contact mapping configuration, enable "Map Distribution lists" and choose iCloud groups for DAV contact groups format.

<!-- gh-comment-id:330886431 --> @aluxnimm commented on GitHub (Sep 20, 2017): Yes this is disabled by default. Advanced settings, contact mapping configuration, enable "Map Distribution lists" and choose iCloud groups for DAV contact groups format.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/outlookcaldavsynchronizer#647
No description provided.