Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117907808
D357.1775392409.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D357.1775392409.diff
View Options
diff --git a/lib/Kolab/CardDAV/ContactsBackend.php b/lib/Kolab/CardDAV/ContactsBackend.php
--- a/lib/Kolab/CardDAV/ContactsBackend.php
+++ b/lib/Kolab/CardDAV/ContactsBackend.php
@@ -982,10 +982,12 @@
break;
case 'PHOTO':
- $param = $prop->offsetGet('encoding') ?: $prop->parameters[0];
- if (($pvalue = $param->getValue()) && (strtolower($pvalue) == 'b' || strtolower($pvalue) == 'base64') || strtolower($param->name) == 'base64') {
+ if ($prop instanceof VObject\Property\Binary && $value) {
$contact['photo'] = $value;
}
+ else if ($prop instanceof VObject\Property\Uri && preg_match('|^data:image/[a-z]+;base64,|i', $value, $m)) {
+ $contact['photo'] = base64_decode(substr($value, strlen($m[0])));
+ }
break;
// VCard 4.0 properties
diff --git a/test/Unit/CardDAV/ContactsBackend.php b/test/Unit/CardDAV/ContactsBackend.php
--- a/test/Unit/CardDAV/ContactsBackend.php
+++ b/test/Unit/CardDAV/ContactsBackend.php
@@ -25,4 +25,31 @@
$this->assertRegexp('/PHOTO;ENCODING=b;TYPE=GIF:R0l/', $vcard);
}
+
+ /**
+ * Test vCard PHOTO (T2043)
+ *
+ * @dataProvider data_T2043
+ */
+ function test_T2043($input, $output, $version)
+ {
+ $backend = new ContactsBackend;
+ $vcard = "BEGIN:VCARD\nVERSION:$version\nN:Thompson;Default;;;\nUID:1\n$input\nEND:VCARD";
+ $contact = $backend->parse_vcard($vcard);
+
+ $this->assertSame($output, $contact['photo']);
+ }
+
+ function data_T2043()
+ {
+ return array(
+ array('PHOTO;JPEG;ENCODING=BASE64:' . base64_encode('abc'), 'abc', '2.1'),
+ array('PHOTO;TYPE=JPEG;ENCODING=b:' . base64_encode('abc'), 'abc', '3.0'),
+ array('PHOTO:data:image/jpeg;base64,'. base64_encode('abc'), 'abc', '4.0'),
+ // As we do not support photo URLs yet we expect NULL here
+ //array('PHOTO;JPEG:http://example.com/photo.jpg', null, '2.1'), // invalid?
+ array('PHOTO;TYPE=JPEG;VALUE=URI:http://example.com/photo.jpg', null, '3.0'),
+ array('PHOTO;MEDIATYPE=image/jpeg:http://example.com/photo.jpg', null, '4.0'),
+ );
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 12:33 PM (14 h, 8 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833454
Default Alt Text
D357.1775392409.diff (2 KB)
Attached To
Mode
D357: Fix PHP fatal errors on some PHOTO property formats
Attached
Detach File
Event Timeline