Changeset fbe7b71 in github
- Timestamp:
- Apr 24, 2012 3:26:04 PM (13 months ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo
- Children:
- 76248c7
- Parents:
- db70b3f
- Files:
-
- 3 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_vcard.php (modified) (5 diffs)
-
tests/vcards.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r19d5973 rfbe7b71 2 2 =========================== 3 3 4 - Fix importing vCard photo with ENCODING param specified (#1488432) 4 5 - Add vCard import from multiple files at once (#1488015) 5 6 - Roundcube Framework: -
program/include/rcube_vcard.php
r0c25968 rfbe7b71 296 296 if (strpos($value, 'http:') === 0) { 297 297 // TODO: fetch file from URL and save it locally? 298 $this->raw['PHOTO'][0] = array(0 => $value, ' URL' => true);298 $this->raw['PHOTO'][0] = array(0 => $value, 'url' => true); 299 299 } 300 300 else { 301 $encoded = !preg_match('![^a-z0-9/=+-]!i', $value); 302 $this->raw['PHOTO'][0] = array(0 => $encoded ? $value : base64_encode($value), 'BASE64' => true); 301 $this->raw['PHOTO'][0] = array(0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value)); 303 302 } 304 303 break; … … 553 552 $entry = array(); 554 553 $field = strtoupper($regs2[1][0]); 554 $enc = null; 555 555 556 556 foreach($regs2[1] as $attrid => $attr) { … … 559 559 if ($key == 'ENCODING') { 560 560 // add next line(s) to value string if QP line end detected 561 while ($value == 'QUOTED-PRINTABLE' && preg_match('/=$/', $lines[$i])) 561 if ($value == 'QUOTED-PRINTABLE') { 562 while (preg_match('/=$/', $lines[$i])) 562 563 $line[2] .= "\n" . $lines[++$i]; 563 564 $ line[2] = self::decode_value($line[2], $value);564 } 565 $enc = $value; 565 566 } 566 else 567 $entry[strtolower($key)] = array_merge((array)$entry[strtolower($key)], (array)self::vcard_unquote($value, ',')); 567 else { 568 $lc_key = strtolower($key); 569 $entry[$lc_key] = array_merge((array)$entry[$lc_key], (array)self::vcard_unquote($value, ',')); 570 } 568 571 } 569 572 else if ($attrid > 0) { 570 $entry[ $key] = true; // true means attr without =value573 $entry[strtolower($key)] = true; // true means attr without =value 571 574 } 572 575 } 573 576 574 $entry = array_merge($entry, (array)self::vcard_unquote($line[2])); 577 // decode value 578 if ($enc || !empty($entry['base64'])) { 579 // save encoding type (#1488432) 580 if ($enc == 'B') { 581 $entry['encoding'] = 'B'; 582 // should we use vCard 3.0 instead? 583 // $entry['base64'] = true; 584 } 585 $line[2] = self::decode_value($line[2], $enc ? $enc : 'base64'); 586 } 587 588 if ($enc != 'B' && empty($entry['base64'])) { 589 $line[2] = self::vcard_unquote($line[2]); 590 } 591 592 $entry = array_merge($entry, (array) $line[2]); 575 593 $data[$field][] = $entry; 576 594 } … … 597 615 598 616 case 'base64': 617 case 'b': 599 618 self::$values_decoded = true; 600 619 return base64_decode($value); … … 628 647 $value = array(); 629 648 foreach($entry as $attrname => $attrvalues) { 630 if (is_int($attrname)) 649 if (is_int($attrname)) { 650 if (!empty($entry['base64']) || $entry['encoding'] == 'B') { 651 $attrvalues = base64_encode($attrvalues); 652 } 631 653 $value[] = $attrvalues; 632 elseif ($attrvalues === true) 633 $attr .= ";$attrname"; // true means just tag, not tag=value, as in PHOTO;BASE64:... 654 } 655 else if (is_bool($attrvalues)) { 656 if ($attrvalues) { 657 $attr .= strtoupper(";$attrname"); // true means just tag, not tag=value, as in PHOTO;BASE64:... 658 } 659 } 634 660 else { 635 661 foreach((array)$attrvalues as $attrvalue) 636 $attr .= ";$attrname=". self::vcard_quote($attrvalue, ',');662 $attr .= strtoupper(";$attrname=") . self::vcard_quote($attrvalue, ','); 637 663 } 638 664 } -
tests/vcards.php
r0fbadeb rfbe7b71 45 45 46 46 $vcards = rcube_vcard::import($input); 47 47 48 48 $this->assertEqual(2, count($vcards), "Detected 2 vcards"); 49 49 $this->assertEqual("Apple Computer AG", $vcards[0]->displayname, "FN => displayname");
Note: See TracChangeset
for help on using the changeset viewer.
