Thanks to badly broken distributions, IDN extension != IDN extension.
authorJan Schneider <jan@horde.org>
Thu, 23 Sep 2010 11:37:43 +0000 (13:37 +0200)
committerJan Schneider <jan@horde.org>
Thu, 23 Sep 2010 11:37:43 +0000 (13:37 +0200)
framework/Mime/lib/Horde/Mime/Address.php
imp/lib/Compose.php
kronolith/lib/Event.php

index 30d3d6c..4ac5e7e 100644 (file)
@@ -53,7 +53,12 @@ class Horde_Mime_Address
         if ((!isset($opts['idn']) || !$opts['idn']) &&
             (stripos($host, 'xn--') === 0) &&
             Horde_Util::extensionExists('idn')) {
-            $host = Horde_String::convertCharset(idn_to_utf8($host), 'UTF-8');
+            if (function_exists('idn_to_utf8')) {
+                $host = idn_to_utf8($host);
+            } elseif (function_exists('idn_punycode_decode')) {
+                $host = idn_punycode_decode($host);
+            }
+            $host = Horde_String::convertCharset($host, 'UTF-8');
         }
 
         $address .= self::encode($mailbox, 'address') . '@' . $host;
index 5be3b61..fb9a624 100644 (file)
@@ -1007,7 +1007,12 @@ class IMP_Compose
         // Convert IDN hosts to ASCII.
         if (Horde_Util::extensionExists('idn')) {
             $old_error = error_reporting(0);
-            $host = idn_to_ascii(Horde_String::convertCharset($host, $GLOBALS['registry']->getCharset(), 'UTF-8'));
+            $host = Horde_String::convertCharset($host, $GLOBALS['registry']->getCharset(), 'UTF-8');
+            if (function_exists('idn_to_ascii')) {
+                $host = idn_to_ascii($host);
+            } elseif (function_exists('idn_punycode_encode')) {
+                $host = idn_punycode_encode($host);
+            }
             error_reporting($old_error);
         } elseif (Horde_Mime::is8bit($ob['mailbox'], $GLOBALS['registry']->getCharset())) {
             throw new IMP_Compose_Exception(sprintf(_("Invalid character in e-mail address: %s."), $email));
index b39d401..94741ad 100644 (file)
@@ -2023,7 +2023,12 @@ abstract class Kronolith_Event
                         // Convert IDN hosts to ASCII.
                         if (Horde_Util::extensionExists('idn')) {
                             $old_error = error_reporting(0);
-                            $url['host'] = idn_to_ascii(Horde_String::convertCharset($url['host'], $GLOBALS['registry']->getCharset(), 'UTF-8'));
+                            $url['host'] = Horde_String::convertCharset($url['host'], $GLOBALS['registry']->getCharset(), 'UTF-8');
+                            if (function_exists('idn_to_ascii')) {
+                                $url['host'] = idn_to_ascii($url['host']);
+                            } elseif (function_exists('idn_punycode_encode')) {
+                                $url['host'] = idn_punycode_encode($url['host']);
+                            }
                             error_reporting($old_error);
                         } elseif (Horde_Mime::is8bit($url['host'])) {
                             //throw new Kronolith_Exception(_("Invalid character in URL."));