From: Florent Bruneau Date: Sat, 15 Sep 2007 16:55:33 +0000 (+0200) Subject: Fucking ugly hack to make vcard works properly on the fucking ugly Windows. X-Git-Tag: xorg/0.9.15~153 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=5175057e1d9b2a93336148506a6074af21368433;p=platal.git Fucking ugly hack to make vcard works properly on the fucking ugly Windows. Signed-off-by: Florent Bruneau --- 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); }