Skip to content

Commit

Permalink
Fix importing birthday dates from Gmail vCards (BDAY:YYYYMMDD)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Aug 12, 2020
1 parent ce22759 commit 0839cdd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,6 +1,8 @@
CHANGELOG Roundcube Webmail
===========================

- Fix importing birthday dates from Gmail vCards (BDAY:YYYYMMDD)

RELEASE 1.4.8
-------------
- Security: Fix potential XSS issue in HTML editor of the identity signature input (#7507)
Expand Down
4 changes: 4 additions & 0 deletions program/lib/Roundcube/rcube_vcard.php
Expand Up @@ -240,6 +240,10 @@ public function get_assoc()
list(,, $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']) = $raw;
$out[$key][] = $value;
}
// support vCard v4 date format (YYYYMMDD)
else if ($tag == 'BDAY' && preg_match('/^([12][90]\d\d)([01]\d)([0123]\d)$/', $raw[0], $m)) {
$out[$key][] = sprintf('%04d-%02d-%02d', intval($m[1]), intval($m[2]), intval($m[3]));
}
else {
$out[$key][] = $raw[0];
}
Expand Down
12 changes: 12 additions & 0 deletions tests/Framework/VCard.php
Expand Up @@ -175,4 +175,16 @@ function test_parse_skip_empty()
$this->assertEquals($result['address:home'][0]['zipcode'], 'zip', "ADR with some fields missing (1)");
$this->assertEquals($result['address:home'][0]['street'], 'street', "ADR with some fields missing (2)");
}

/**
* Support BDAT in YYYYMMRR format
*/
function test_bday_v4()
{
$vcard = "BEGIN:VCARD\nVERSION:4.0\nN:last\\;;first\\\\;middle\\\\\\;\\\\;prefix;\nFN:test\nBDAY:19800202\nEND:VCARD";
$vcard = new rcube_vcard($vcard, null);
$vcard = $vcard->get_assoc();

$this->assertEquals("1980-02-02", $vcard['birthday'][0]);
}
}

0 comments on commit 0839cdd

Please sign in to comment.