Changeset 4575 in subversion
- Timestamp:
- Feb 27, 2011 8:30:34 AM (2 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 1 added
- 4 edited
-
program/include/rcube_vcard.php (modified) (6 diffs)
-
program/steps/addressbook/func.inc (modified) (2 diffs)
-
program/steps/addressbook/import.inc (modified) (1 diff)
-
tests/src/utf-16_sample.vcf (added)
-
tests/vcards.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcube_vcard.php
r4541 r4575 41 41 'email' => 'EMAIL', 42 42 'address' => 'ADR', 43 'jobtitle' => 'TITLE', 43 44 'gender' => 'X-GENDER', 44 45 'maidenname' => 'X-MAIDENNAME', … … 166 167 } 167 168 } 169 170 // force subtype if none set 171 if (preg_match('/^(email|phone|address|website)/', $key) && !$subtype) 172 $subtype = 'other'; 168 173 169 174 if ($subtype) … … 278 283 279 284 case 'photo': 280 $encoded = !preg_match('![^a-z0-9/=+-]!i', $value); 281 $this->raw['PHOTO'][0] = array(0 => $encoded ? $value : base64_encode($value), 'BASE64' => true); 285 if (strpos($value, 'http:') === 0) { 286 // TODO: fetch file from URL and save it locally? 287 $this->raw['PHOTO'][0] = array(0 => $value, 'URL' => true); 288 } 289 else { 290 $encoded = !preg_match('![^a-z0-9/=+-]!i', $value); 291 $this->raw['PHOTO'][0] = array(0 => $encoded ? $value : base64_encode($value), 'BASE64' => true); 292 } 282 293 break; 283 294 … … 423 434 // Convert special types (like Skype) to normal type='skype' classes with this simple regex ;) 424 435 $vcard = preg_replace( 425 '/item(\d+)\.(TEL| URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w-() ]*)(?:>!\$_)?./s',436 '/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w-() ]*)(?:>!\$_)?./s', 426 437 '\2;type=\5\3:\4', 438 $vcard); 439 440 // convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility 441 $vcard = preg_replace_callback( 442 '/item(\d+)\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w-() ]*)(?:>!\$_)?./s', 443 array('self', 'x_abrelatednames_callback'), 427 444 $vcard); 428 445 … … 440 457 441 458 return $vcard; 459 } 460 461 private static function x_abrelatednames_callback($matches) 462 { 463 return 'X-' . strtoupper($matches[5]) . $matches[3] . ':'. $matches[4]; 442 464 } 443 465 … … 632 654 if (substr($string, 0, 3) == "\xEF\xBB\xBF") return 'UTF-8'; 633 655 656 // heuristics 657 if ($string[0] == "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-32BE'; 658 if ($string[0] != "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] == "\0") return 'UTF-32LE'; 659 if ($string[0] == "\0" && $string[1] != "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-16BE'; 660 if ($string[0] != "\0" && $string[1] == "\0" && $string[2] != "\0" && $string[3] == "\0") return 'UTF-16LE'; 661 634 662 // use mb_detect_encoding() 635 663 $encodings = array('UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', -
trunk/roundcubemail/program/steps/addressbook/func.inc
r4527 r4575 366 366 if (!$coltypes[$col]) 367 367 continue; 368 369 // only string values are expected here 370 if (is_array($record[$col])) 371 $record[$col] = join(' ', $record[$col]); 368 372 369 373 if ($RCMAIL->action == 'show') { … … 564 568 $RCMAIL->output->set_env('photo_placeholder', $photo_img); 565 569 566 if ($record['photo']) 570 if (strpos($record['photo'], 'http:') === 0) 571 $photo_img = $record['photo']; 572 else if ($record['photo']) 567 573 $photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $_REQUEST['_source'])); 568 574 $img = html::img(array('src' => $photo_img, 'border' => 1, 'alt' => '')); -
trunk/roundcubemail/program/steps/addressbook/import.inc
r4484 r4575 139 139 $email = rcube_idn_to_utf8($email); 140 140 141 if (!$replace ) {141 if (!$replace && $email) { 142 142 // compare e-mail address 143 143 $existing = $CONTACTS->search('email', $email, false, false); -
trunk/roundcubemail/tests/vcards.php
r4393 r4575 55 55 } 56 56 57 function test_encodings() 58 { 59 $input = file_get_contents($this->_srcpath('utf-16_sample.vcf')); 60 61 $vcards = rcube_vcard::import($input); 62 $this->assertEqual("njgean ĜdaMonté", $vcards[0]->displayname, "Decoded from UTF-16"); 63 } 64 57 65 }
Note: See TracChangeset
for help on using the changeset viewer.
