Skip to content

Commit 792ca98

Browse files
committed
Merge pull request #64 from DominikTo/master
fixed binary converter issue
2 parents f50566b + 509eba2 commit 792ca98

File tree

4 files changed

+398
-0
lines changed

4 files changed

+398
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* Added: --forgiving option to vobject utility.
2020
* Fixed: Compound properties such as ADR were not correctly split up in
2121
vCard 2.1 quoted printable-encoded properties.
22+
* Fixed: Issue 64: Encoding of binary properties of converted vCards.
23+
Thanks @DominikTo for the patch.
2224

2325
3.1.2-stable (2013-08-13)
2426
* Fixed: Setting correct property group on VCard conversion

lib/Sabre/VObject/Property/Binary.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ class Binary extends Property {
3030
*/
3131
public $delimiter = null;
3232

33+
/**
34+
* Updates the current value.
35+
*
36+
* This may be either a single, or multiple strings in an array.
37+
*
38+
* @param string|array $value
39+
* @return void
40+
*/
41+
public function setValue($value) {
42+
43+
if(is_array($value)) {
44+
45+
if(count($value) === 1) {
46+
$this->value = $value[0];
47+
} else {
48+
throw new \InvalidArgumentException('The argument must either be a string or an array with only one child');
49+
}
50+
51+
} else {
52+
53+
$this->value = $value;
54+
55+
}
56+
57+
}
58+
3359
/**
3460
* Sets a raw value coming from a mimedir (iCalendar/vCard) file.
3561
*
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Sabre\VObject;
4+
5+
class Issue64Test extends \PHPUnit_Framework_TestCase {
6+
7+
function testRead() {
8+
9+
$vcard = Reader::read(file_get_contents(dirname(__FILE__) . '/issue64.vcf'));
10+
$vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
11+
$vcard = $vcard->serialize();
12+
13+
$converted = Reader::read($vcard);
14+
15+
$this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $converted);
16+
17+
}
18+
19+
}

0 commit comments

Comments
 (0)