From fc97a867ee732254b36e4abb095fdb9e2dd404df Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 17 Nov 2024 00:53:31 +0100 Subject: [PATCH] Fix vCard output #31958 Fix #31958 - avoid messing up ENCODIGN & add CHARSET Workaround by limiting the too generic replacement for social networks. Add CHARSET for proper decoding. --- htdocs/core/class/vcard.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index 9e68c6669c508..d447c0b701069 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -2,6 +2,7 @@ /* Copyright (C) Kai Blankenhorn * Copyright (C) 2005-2017 Laurent Destailleur * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * 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 @@ -100,7 +101,7 @@ class vCard /** * @var string encoding */ - public $encoding = "ENCODING=QUOTED-PRINTABLE"; + public $encoding = "CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE"; /** @@ -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")); @@ -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); //} } @@ -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('/(?