From 5175057e1d9b2a93336148506a6074af21368433 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 15 Sep 2007 18:55:33 +0200 Subject: [PATCH] Fucking ugly hack to make vcard works properly on the fucking ugly Windows. Signed-off-by: Florent Bruneau --- include/vcard.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/vcard.inc.php b/include/vcard.inc.php index f357f74..f858b8a 100644 --- a/include/vcard.inc.php +++ b/include/vcard.inc.php @@ -108,11 +108,13 @@ class VCardIterator implements PlIterator class VCard { + static private $windows = false; private $iterator = null; public function __construct($users, $photos = true, $freetext = null) { $this->iterator = new VCardIterator($photos, $freetext); + VCard::$windows = (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false); if (is_array($users)) { foreach ($users as $user) { $this->iterator->add_user($user); @@ -124,7 +126,11 @@ class VCard public static function escape($text) { - return preg_replace('/[,;]/', '\\\\$0', $text); + if (VCard::$windows) { + return preg_replace('/;/', '\\\\$0', $text); + } else { + return preg_replace('/[,;]/', '\\\\$0', $text); + } } public static function format_adr($params, &$smarty) @@ -150,6 +156,9 @@ class VCard if ($escape) { $text = VCard::escape($text); } + if (VCard::$windows) { + $text = utf8_decode($text); + } return preg_replace("/(\r\n|\n|\r)/", '\n', $text); } -- 2.1.4