Skip to content

Commit

Permalink
Move un-quote code to vCard parser
Browse files Browse the repository at this point in the history
  • Loading branch information
derwok committed Jan 12, 2019
1 parent 67ddf0e commit 980e461
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/FritzBox/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function convert($card)
// add Person
$person = $this->contact->addChild('person');
$realName = htmlspecialchars($this->getProperty('realName'));
$realName = preg_replace("/\\\\([,\\\\])/", "$1", $realName); // remove quote backslashes
$realName = preg_replace("/\\ +/", " ", $realName); // clean up multiple spaces
$person->addChild('realName', $realName);
// add photo
if (isset($this->card->rawPhoto) && isset($this->card->imageURL)) {
Expand Down
7 changes: 7 additions & 0 deletions src/Vcard/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ protected function parse()
$i++;
}

// Unquote COMMA and BACKSPACE as per RFC 6350 chap. 3.4
// https://tools.ietf.org/html/rfc6350#section-3.4
// But don't do this on potential binary data!
if (!$rawValue) {
$value = preg_replace("/\\\\([,\\\\])/", "$1", $value); // remove quote backslashes
}

switch (strtoupper($element)) {
case 'FN':
$cardData->fullname = $value;
Expand Down

0 comments on commit 980e461

Please sign in to comment.