Skip to content

Commit

Permalink
Fix vCard output #31958 (#31959)
Browse files Browse the repository at this point in the history
Fix #31958 - avoid messing up ENCODIGN & add CHARSET

Workaround by limiting the too generic replacement for social networks.
Add CHARSET for proper decoding.
  • Loading branch information
mdeweerd authored Nov 17, 2024
1 parent 54891e8 commit 860e1b7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions htdocs/core/class/vcard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) Kai Blankenhorn <[email protected]>
* Copyright (C) 2005-2017 Laurent Destailleur <[email protected]>
* Copyright (C) 2020 Tobias Sekan <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -100,7 +101,7 @@ class vCard
/**
* @var string encoding
*/
public $encoding = "ENCODING=QUOTED-PRINTABLE";
public $encoding = "CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE";


/**
Expand Down Expand Up @@ -163,7 +164,7 @@ public function setFormattedName($name)
public function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "")
{
//$this->properties["N;".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
$this->properties["N"] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
$this->properties["N;".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
$this->filename = "$first%20$family.vcf";
if (empty($this->properties["FN"])) {
$this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
Expand Down Expand Up @@ -211,7 +212,7 @@ public function setAddress($postoffice = "", $extended = "", $street = "", $city
$this->properties[$key] = encode($postoffice).";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);

//if ($this->properties["LABEL;".$type.";".$this->encoding] == '') {
//$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type);
//$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type);
//}
}

Expand Down Expand Up @@ -362,7 +363,7 @@ public function getVCard()
$text .= "VERSION:4.0\r\n"; // With V4, all encoding are UTF-8
//$text.= "VERSION:2.1\r\n";
foreach ($this->properties as $key => $value) {
$newkey = preg_replace('/-.*$/', '', $key); // remove suffix -twitter, -facebook, ...
$newkey = preg_replace('/(?<!QUOTED|UTF)-.*$/', '', $key); // remove suffix -twitter, -facebook, ...
$text .= $newkey.":".$value."\r\n";
}
$text .= "REV:".date("Ymd")."T".date("His")."Z\r\n";
Expand Down

0 comments on commit 860e1b7

Please sign in to comment.