Changeset e9aa8c6 in github


Ignore:
Timestamp:
Jan 22, 2011 9:00:22 AM (2 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
de06fc3
Parents:
ede1744
Message:

Improve parsing of vCards exported by MS Outlook (#1487716)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_vcard.php

    r0501b63 re9aa8c6  
    148148          $k = -1; 
    149149          $key = $col; 
     150           
    150151          $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]); 
    151152          while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) 
    152153            $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]); 
     154           
     155          // read vcard 2.1 subtype 
     156          if (!$subtype) { 
     157            foreach ($raw as $k => $v) { 
     158              if (!is_numeric($k) && $v === true && !in_array(strtolower($k), array('pref','internet','voice','base64'))) { 
     159                $subtype = $typemap[$k] ? $typemap[$k] : strtolower($k); 
     160                break; 
     161              } 
     162            } 
     163          } 
     164           
    153165          if ($subtype) 
    154166            $key .= ':' . $subtype; 
     
    279291 
    280292      case 'birthday': 
    281         if ($val = @strtotime($value)) 
     293        if ($val = rcube_strtotime($value)) 
    282294          $this->raw['BDAY'][] = array(0 => date('Y-m-d', $val), 'value' => array('date')); 
    283295        break; 
     
    413425    // Remove cruft like item1.X-AB*, item1.ADR instead of ADR, and empty lines 
    414426    $vcard = preg_replace(array('/^item\d*\.X-AB.*$/m', '/^item\d*\./m', "/\n+/"), array('', '', "\n"), $vcard); 
     427     
     428    // convert X-WAB-GENDER to X-GENDER 
     429    if (preg_match('/X-WAB-GENDER:(\d)/', $vcard, $matches)) { 
     430      $value = $matches[1] == '2' ? 'male' : 'female'; 
     431      $vcard = preg_replace('/X-WAB-GENDER:\d/', 'X-GENDER:' . $value, $vcard); 
     432    } 
    415433 
    416434    // if N doesn't have any semicolons, add some  
Note: See TracChangeset for help on using the changeset viewer.