Re: [evolution-patches] IDN patch for evolution head



On Wed, 2003-12-31 at 12:16 -0800, Suresh Chandrasekharan wrote:
Pl. use this patch.evolution-1.5, this one contains updated configure.in
changes. All the others remain same.

Some comments on the mailer related stuff below

Regards,
Suresh

2003/12/28 (日) 20:38 に Suresh Chandrasekharan さんは書きました:
> Hi All,
>     Attached are the patches for idnkit library, evolution-1.5, have
> incorporated rodo's feedback and have made the changes.
> 
> Pl. check whether these are OK.
> 
> Thanks,
> Suresh



I'll only comment on the mail stuff.


> Index: camel/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
> retrieving revision 1.1945
> diff -u -r1.1945 ChangeLog
> --- camel/ChangeLog 24 Dec 2003 16:29:40 -0000 1.1945
> +++ camel/ChangeLog 31 Dec 2003 19:03:07 -0000
> @@ -1,3 +1,52 @@
> +2003-12-27  Suresh Chandrasekharan <suresh chandrasekharan sun com>
> +
> + * International Domain Names (IDN) support for Evolution.
> +
> + * camel-http-stream.c: (http_method_invoke) When sending a http stream
> + make sure that hostname is encoded in ACE.
> +
> + * camel-url-scanner.c: (camel_url_web_end) The end of valid
> + hostname seach is modified to include non-ASCII.
> +
> + (is_idn_domain) New function added to determine whether a
> + non-ASCII hostname is valid.
> +
> + * camel-url.h: utf8_host is added to CamelURL.
> +
> + * camel-url.c: (camel_url_new_with_base) Coroesponding to each
> + host_name, store a utf8 hostname too. This will help save calls
> + to idn functions when the utf8_host is required repeatedly for a
> + utf8_host. Call to camel_url_decode is not made because
> + e_uri_decode_host will inturn call that.
> +
> + (camel_url_copy) Added  utf8_host.
> +
> + * providers/imap/camel-imap-store.c: (imap_get_name) Show utf8
> + hostname in user messages.
> +
> + (connect_to_server) Same as above
> +
> + (imap_auth_loop) Show utf8 hostname when asking for password.
> +
> + * providers/nntp/camel-nntp-store.c: (connect_to_server) Show utf8
> + hostname in erro messages.
> +
> + (nntp_store_get_name)  Show utf8  hostname in user messages.
> +
> + * providers/pop3/camel-pop3-store.c: (connect_to_server): Show utf8
> + hostname in error messages.
> +
> + (query_auth_types) Same
> +
> + (pop3_try_authenticate) Show utf8 hostname when asking for password.
> +
> + * providers/smtp/camel-smtp-transport.c: (connect_to_server) utf8
> + hostname in error messages when not able to connect.
> +
> + (smtp_connect) Same
> +
> + (get_name) utf8 name in status display.
> +
>  2003-12-24  Rodrigo Moya <rodrigo ximian com>

>  * providers/groupwise/camel-groupwise-provider.c
> Index: camel/camel-http-stream.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/camel-http-stream.c,v
> retrieving revision 1.16
> diff -u -r1.16 camel-http-stream.c
> --- camel/camel-http-stream.c 23 Oct 2003 19:57:58 -0000 1.16
> +++ camel/camel-http-stream.c 31 Dec 2003 19:03:07 -0000
> @@ -31,6 +31,8 @@
>  #include <ctype.h>
>  #include <errno.h>

> +#include "e-util/e-url.h"
> +
>  #include "camel-http-stream.h"

>  #include "camel-mime-utils.h"
> @@ -344,6 +346,7 @@
>  {
>  const char *method = NULL;
>  char *url;
> + char *t = NULL;

>  switch (http->method) {
>  case CAMEL_HTTP_METHOD_GET:
> @@ -357,21 +360,24 @@
>  }

>  url = "" (http->url, 0);
> + t = e_uri_encode_host (http->url->host);

idea right, but it should be a method off camel-url.

>  d(printf("HTTP Stream Sending: %s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
>  method,
>  http->proxy ? url : http->url->path,
> - http->user_agent ? http->user_agent : "CamelHttpStream/1.0",
> - http->url->host));
> + http->user_agent ? http->user_agent : "CamelHttpStream/1.0",
> + t));
>  if (camel_stream_printf (http->raw, "%s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
>  method,
>  http->proxy ? url : http->url->path,
>  http->user_agent ? http->user_agent : "CamelHttpStream/1.0",
> - http->url->host) == -1) {
> + t) == -1) {
>  http_disconnect(http);
>  g_free (url);
> + g_free (t);
>  return -1;
>  }
>  g_free (url);
> + g_free (t);

>  if (http->authrealm)
>  d(printf("HTTP Stream Sending: WWW-Authenticate: %s\n", http->authrealm));
> Index: camel/camel-service.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/camel-service.h,v
> retrieving revision 1.49
> diff -u -r1.49 camel-service.h
> --- camel/camel-service.h 8 May 2002 21:58:37 -0000 1.49
> +++ camel/camel-service.h 31 Dec 2003 19:03:07 -0000
> @@ -33,6 +33,7 @@
>  #pragma }
>  #endif /* __cplusplus }*/

> +#include "config.h"
>  #include <netdb.h>
>  #include <camel/camel-object.h>
>  #include <camel/camel-url.h>
> @@ -44,6 +45,14 @@
>  #define CAMEL_SERVICE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass))
>  #define CAMEL_IS_SERVICE(o)    (CAMEL_CHECK_TYPE((o), CAMEL_SERVICE_TYPE))

> +#ifdef ENABLE_IDN
> +#define DISP_HOST(service) (service)->url->utf8_host ?  \

This should really be a method/macro off camel-url, and it should be namespaced.

> + (service)->url->utf8_host : \
> + (service)->url->host
> +#else
> +#define DISP_HOST(service) (service)->url->host
> +#endif
> +
>  enum {
>  CAMEL_SERVICE_ARG_FIRST  = CAMEL_ARG_FIRST + 100,
>  CAMEL_SERVICE_ARG_USERNAME,
> Index: camel/camel-url-scanner.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/camel-url-scanner.c,v
> retrieving revision 1.6
> diff -u -r1.6 camel-url-scanner.c
> --- camel/camel-url-scanner.c 17 Apr 2003 16:43:06 -0000 1.6
> +++ camel/camel-url-scanner.c 31 Dec 2003 19:03:08 -0000
> @@ -27,6 +27,7 @@

>  #include <string.h>

> +#include "e-util/e-url.h"
>  #include "e-util/e-trie.h"
>  #include "camel-url-scanner.h"

> @@ -36,6 +37,9 @@
>  ETrie *trie;
>  };

> +#ifdef ENABLE_IDN
> +static gboolean is_idn_domain ( const char **inptr, const char *inend);
> +#endif

>  CamelUrlScanner *
>  camel_url_scanner_new (void)
> @@ -209,10 +213,8 @@
>  inptr++;
>  else
>  break;
> -
>  while (inptr < inend && is_domain (*inptr))
>  inptr++;
> -
>  if (inptr < inend && *inptr == '.' && is_domain (inptr[1]))
>  inptr++;
>  }
> @@ -236,6 +238,7 @@
>  { '<', '>' },
>  };

> +
>  static char
>  url_stop_at_brace (const char *in, size_t so)
>  {
> @@ -251,6 +254,31 @@
>  return '\0';
>  }

> +#ifdef ENABLE_IDN
> +static gboolean
> +is_idn_domain ( const char **inptr, const char *inend) {
> + char *t;
> + char inbuf[16];
> + gint len = 0;
> +
> + memset (inbuf, 0, sizeof (inbuf));
> + g_utf8_strncpy (inbuf, *inptr, 1);
> + t = e_uri_encode_host (inbuf);
> + if (t) {
> + g_free (t);
> + len = strlen (inbuf);
> + if (*inptr + len <= inend ) {
> + *inptr += len;
> + return TRUE;
> + }
> + } else if (is_domain (**inptr)) {
> + *inptr += 1;
> + return TRUE;
> + }
> + return FALSE;
> +}


Is there a better way to do this?  Isn't there a pretty fixed/simple
set of valid characters?

> +#endif
> +
>  gboolean
>  camel_url_file_start (const char *in, const char *pos, const char *inend, urlmatch_t *match)
>  {
> @@ -294,7 +322,7 @@
>  gboolean
>  camel_url_web_end (const char *in, const char *pos, const char *inend, urlmatch_t *match)
>  {
> - register const char *inptr = pos;
> + const char *inptr = pos;
>  int parts = 0, digits, port;
>  char close_brace;

> @@ -320,18 +348,32 @@
>  inptr++;

>  } while (parts < 4);
> +#ifdef ENABLE_IDN
> + } else if (is_idn_domain (&inptr, inend)) {
> +#else
>  } else if (is_domain (*inptr)) {
> - while (inptr < inend) {
> +#endif
> + while (inptr < inend) {
> +#ifdef ENABLE_IDN
> + if (!is_idn_domain (&inptr, inend))
> + break;
> +
> + while (inptr < inend && is_idn_domain (&inptr, inend));
> +
> + if (inptr < inend && *inptr == '.' )
> + is_idn_domain (&(inptr)+1, inend);
> +#else
>  if (is_domain (*inptr))
>  inptr++;
>  else
>  break;
> -
> +
>  while (inptr < inend && is_domain (*inptr))
>  inptr++;
> -
> +
>  if (inptr < inend && *inptr == '.' && is_domain (inptr[1]))
>  inptr++;
> +#endif
>  }
>  } else {
>  return FALSE;
> Index: camel/camel-url.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/camel-url.c,v
> retrieving revision 1.38
> diff -u -r1.38 camel-url.c
> --- camel/camel-url.c 9 Dec 2003 00:58:40 -0000 1.38
> +++ camel/camel-url.c 31 Dec 2003 19:03:08 -0000
> @@ -32,6 +32,8 @@
>  #include <stdlib.h>
>  #include <string.h>

> +#include "e-util/e-url.h"
> +
>  #include "camel-url.h"
>  #include "camel-exception.h"
>  #include "camel-mime-utils.h"
> @@ -126,10 +128,17 @@
>  colon = strchr (url_string, ':');
>  if (colon && colon < slash) {
>  url->host = g_strndup (url_string, colon - url_string);
> +#ifdef ENABLE_IDN
> +                        url->utf8_host = e_uri_decode_host (url->host);

CamelURL must be independent of EUri.  You're only saving some glue to libidn anyway.

Is there any reason the host wouldn't ALWAYS be in utf8 or compatible
format (i.e. isn't an ascii hostname also a utf8 one?).

> +#endif
>  url->port = strtoul (colon + 1, NULL, 10);
>  } else {
>  url->host = g_strndup (url_string, slash - url_string);
> - camel_url_decode (url->host);
> +#ifdef ENABLE_IDN
> +                        url->utf8_host = e_uri_decode_host (url->host);
> +#else /* Don't need decoding for utf8_host */
> +                        camel_url_decode (url->host);
> +#endif
>  url->port = 0;
>  }

> @@ -187,6 +196,9 @@
>  else if (base && !url->protocol) {
>  if (!url->user && !url->authmech && !url->passwd &&
>      !url->host && !url->port && !url->path &&
> +#ifdef ENABLE_IDN
> +                    !url->utf8_host &&
> +#endif
>      !url->params && !url->query && !url->fragment)
>  url->fragment = g_strdup (base->fragment);

> @@ -195,6 +207,9 @@
>  url->authmech = g_strdup (base->authmech);
>  url->passwd = g_strdup (base->passwd);
>  url->host = g_strdup (base->host);
> +#ifdef ENABLE_IDN
> +                url->utf8_host = g_strdup (base->utf8_host);
> +#endif
>  url->port = base->port;

>  if (!url->path) {
> Index: camel/camel-url.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/camel-url.h,v
> retrieving revision 1.19
> diff -u -r1.19 camel-url.h
> --- camel/camel-url.h 23 Apr 2003 01:34:02 -0000 1.19
> +++ camel/camel-url.h 31 Dec 2003 19:03:08 -0000
> @@ -42,6 +42,9 @@
>  char  *authmech;
>  char  *passwd;
>  char  *host;
> +#ifdef ENABLE_IDN
> +        char  *utf8_host;
> +#endif
>  int    port;
>  char  *path;
>  GData *params;
> Index: camel/providers/imap/camel-imap-store.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/providers/imap/camel-imap-store.c,v
> retrieving revision 1.262
> diff -u -r1.262 camel-imap-store.c
> --- camel/providers/imap/camel-imap-store.c 10 Dec 2003 19:22:20 -0000 1.262
> +++ camel/providers/imap/camel-imap-store.c 31 Dec 2003 19:03:08 -0000
> @@ -456,10 +456,10 @@
>  imap_get_name (CamelService *service, gboolean brief)
>  {
>  if (brief)
> - return g_strdup_printf (_("IMAP server %s"), service->url->host);
> + return g_strdup_printf (_("IMAP server %s"), DISP_HOST(service));
>  else
>  return g_strdup_printf (_("IMAP service for %s on %s"),
> - service->url->user, service->url->host);
> + service->url->user, DISP_HOST(service));
>  }

*if* you're going to do this, DISP_HOST should be a function on camel_url (it could be implemented
as a macro).

But is it really required?  Can't it always be in display/utf8 format when in decoded format?

>  static void
> @@ -600,7 +600,8 @@
>  else
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
>        _("Could not connect to %s (port %d): %s"),
> -       service->url->host, port, g_strerror (errno));
> +       DISP_HOST(service),
> +       port, g_strerror (errno));

>  camel_object_unref (CAMEL_OBJECT (tcp_stream));

> @@ -663,7 +664,8 @@
>  /* server doesn't support STARTTLS, abort */
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to IMAP server %s in secure mode: %s"),
> -       service->url->host, _("SSL/TLS extension not supported."));
> +       DISP_HOST(service),
> +       _("SSL/TLS extension not supported."));
>  /* we have the possibility of quitting cleanly here */
>  clean_quit = TRUE;
>  goto exception;
> @@ -694,7 +696,8 @@
>  if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to IMAP server %s in secure mode: %s"),
> -       service->url->host, _("SSL negotiations failed"));
> +       DISP_HOST(service),
> +       _("SSL negotiations failed"));
>  goto exception;
>  }

> @@ -1246,7 +1249,7 @@
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
>        _("IMAP server %s does not support requested "
>  "authentication type %s"),
> -       service->url->host,
> +       DISP_HOST(service),
>        service->url->authmech);
>  return FALSE;
>  }
> @@ -1281,7 +1284,7 @@
>      "password for %s %s"),
>    errbuf ? errbuf : "",
>    service->url->user,
> -   service->url->host);
> +   DISP_HOST(service));
>  service->url->passwd =
>  camel_session_get_password (session, prompt, FALSE, TRUE,
>      service, "password", ex);
> Index: camel/providers/nntp/camel-nntp-store.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-store.c,v
> retrieving revision 1.54
> diff -u -r1.54 camel-nntp-store.c
> --- camel/providers/nntp/camel-nntp-store.c 22 Sep 2003 15:00:59 -0000 1.54
> +++ camel/providers/nntp/camel-nntp-store.c 31 Dec 2003 19:03:08 -0000
> @@ -129,7 +129,8 @@
>  else
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
>        _("Could not connect to %s (port %d): %s"),
> -       service->url->host, port, g_strerror (errno));
> +             DISP_HOST(service),
> +       port, g_strerror (errno));

>  camel_object_unref (CAMEL_OBJECT (tcp_stream));

> @@ -147,7 +148,8 @@
>  else
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
>        _("Could not read greeting from %s: %s"),
> -       service->url->host, g_strerror (errno));
> +             DISP_HOST(service),
> +       g_strerror (errno));

>  camel_object_unref (CAMEL_OBJECT (store->stream));
>  store->stream = NULL;
> @@ -159,7 +161,7 @@
>  if (len != 200 && len != 201) {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("NNTP server %s returned error code %d: %s"),
> -       service->url->host, len, buf);
> +             DISP_HOST(service), len, buf);

>  camel_object_unref (CAMEL_OBJECT (store->stream));
>  store->stream = NULL;
> @@ -255,9 +257,10 @@
>  nntp_store_get_name (CamelService *service, gboolean brief)
>  {
>  if (brief)
> - return g_strdup_printf ("%s", service->url->host);
> + return g_strdup_printf ("%s", DISP_HOST(service));
>  else
> - return g_strdup_printf (_("USENET News via %s"), service->url->host);
> + return g_strdup_printf (_("USENET News via %s"),
> +       DISP_HOST(service));

>  }

> Index: camel/providers/pop3/camel-pop3-store.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/providers/pop3/camel-pop3-store.c,v
> retrieving revision 1.101
> diff -u -r1.101 camel-pop3-store.c
> --- camel/providers/pop3/camel-pop3-store.c 28 Oct 2003 19:01:56 -0000 1.101
> +++ camel/providers/pop3/camel-pop3-store.c 31 Dec 2003 19:03:08 -0000
> @@ -195,7 +195,8 @@
>  else
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
>        _("Could not connect to POP server %s (port %d): %s"),
> -       service->url->host, port, g_strerror (errno));
> +             DISP_HOST(service),
> +       port, g_strerror (errno));

>  camel_object_unref (CAMEL_OBJECT (tcp_stream));

> @@ -227,7 +228,8 @@
>  /* server doesn't support STARTTLS, abort */
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to POP server %s in secure mode: %s"),
> -       service->url->host, _("SSL/TLS extension not supported."));
> +             DISP_HOST(service),
> +       _("SSL/TLS extension not supported."));
>  /* we have the possibility of quitting cleanly here */
>  clean_quit = TRUE;
>  goto stls_exception;
> @@ -256,7 +258,8 @@
>  if (ret == FALSE) {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to POP server %s in secure mode: %s"),
> -       service->url->host, store->engine->line);
> +             DISP_HOST(service),
> +       store->engine->line);
>  goto stls_exception;
>  }

> @@ -268,7 +271,8 @@
>  if (ret == -1) {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to POP server %s in secure mode: %s"),
> -       service->url->host, _("SSL negotiations failed"));
> +             DISP_HOST(service),
> +       _("SSL negotiations failed"));
>  goto stls_exception;
>  }

> @@ -366,7 +370,7 @@
>  } else {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
>        _("Could not connect to POP server %s"),
> -       service->url->host);
> +             DISP_HOST(service));
>  }

>  return types;
> @@ -478,7 +482,7 @@
>  prompt = g_strdup_printf (_("%sPlease enter the POP password for %s %s"),
>    errmsg ? errmsg : "",
>    service->url->user,
> -   service->url->host);
> +         DISP_HOST(service));
>  service->url->passwd = camel_session_get_password (camel_service_get_session (service),
>     prompt, reprompt, TRUE, service, "password", ex);
>  g_free (prompt);
> Index: camel/providers/smtp/camel-smtp-transport.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/providers/smtp/camel-smtp-transport.c,v
> retrieving revision 1.150
> diff -u -r1.150 camel-smtp-transport.c
> --- camel/providers/smtp/camel-smtp-transport.c 9 Dec 2003 00:58:46 -0000 1.150
> +++ camel/providers/smtp/camel-smtp-transport.c 31 Dec 2003 19:03:09 -0000
> @@ -283,7 +283,8 @@
>  if (ret == -1) {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
>        _("Could not connect to %s (port %d): %s"),
> -       service->url->host, port,
> +             DISP_HOST(service),
> +       port,
>        g_strerror (errno));

>  camel_object_unref (tcp_stream);
> @@ -341,7 +342,8 @@
>  /* server doesn't support STARTTLS, abort */
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to SMTP server %s in secure mode: %s"),
> -       service->url->host, _("server does not appear to support SSL"));
> +             DISP_HOST(service),
> +       _("server does not appear to support SSL"));
>  goto exception_cleanup;
>  }
>  }
> @@ -380,7 +382,8 @@
>  if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
>        _("Failed to connect to SMTP server %s in secure mode: %s"),
> -       service->url->host, g_strerror (errno));
> +             DISP_HOST(service),
> +       g_strerror (errno));
>  goto exception_cleanup;
>  }

> @@ -475,7 +478,8 @@
>  camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
>        _("SMTP server %s does not support requested "
>  "authentication type %s."),
> -       service->url->host, service->url->authmech);
> +             DISP_HOST(service),
> +       service->url->authmech);
>  camel_service_disconnect (service, TRUE, NULL);
>  return FALSE;
>  }
> @@ -513,7 +517,7 @@

>  prompt = g_strdup_printf (_("%sPlease enter the SMTP password for %s %s"),
>    errbuf ? errbuf : "", service->url->user,
> -   service->url->host);
> +         DISP_HOST(service));

>  service->url->passwd = camel_session_get_password (session, prompt, FALSE, TRUE,
>     service, "password", ex);
> @@ -663,11 +667,11 @@
>  get_name (CamelService *service, gboolean brief)
>  {
>  if (brief)
> - return g_strdup_printf (_("SMTP server %s"), service->url->host);
> - else {
> + return g_strdup_printf (_("SMTP server %s"),
> +         DISP_HOST(service));
> + else
>  return g_strdup_printf (_("SMTP mail delivery via %s"),
> - service->url->host);
> - }
> +         DISP_HOST(service));
>  }

>  static gboolean
> Index: e-util/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
> retrieving revision 1.427
> diff -u -r1.427 ChangeLog
> --- e-util/ChangeLog 6 Dec 2003 18:15:20 -0000 1.427
> +++ e-util/ChangeLog 31 Dec 2003 19:03:09 -0000
> @@ -1,3 +1,62 @@
> +2003-12-27  Suresh Chandrasekharan <suresh chandrasekharan sun com>
> +
> + * e-account.c: (xml_set_service) When setting EAccount fileds from
> + xml source, put in hostname in ASCII compatible format.

Why is this required?  Shouldn't they already be in ascii compatible
format if they are stored, or conversely, they can safely be written
in utf8 format.

> + (e_account_to_xml) When writing out xmlDoc from EAccount write it
> + in ASCII compatible format.
> +
> + These two changes make sure that internal to evolution only the
> + ASCII compatible host names are used.


> + * e-html-utils.c: (url_extract) Validate non-ASCII urls for
> + making them 'clickable' display in addressbook contact display.
> +
> + * e-url.c: (e_uri_new) Modified to return the right hostname part of a
> + uri, even if it does not contain a '://' part. Eg. "mailto:abc cde org"
> + now gets parsed correctly.  uri_decode function won't be called if
> + ENABLE_IDN flag is set.

There seems to be a lot of changes here.  This code looks like it was
based on camel-url, which has a test suite which i would guess these
changes would break.

> + (e_uri_copy) Added an additional parameter called host_offset, used
> + in replacing the original UTF-8 hostname by the ACE encoded or vice
> + versa.

You did?  Where?

> + (e_uri_to_string) Fixed the bug causing the removal of the '/'
> + seperating the path name from the rest of url when EUri is converted
> + back to string.

Again, you did, where?

> + The folowing functions are added,
> +
> + (e_uri_encode_host) Pass in a UTF-8 host name and and ACE name will be
> + returned. Made robust by additional checks for encoded url etc.
> +
> + (e_uri_decode_host) Pass in an ACE host name and the equivalent UTF-8
> + hostname will be returned. This functions is made robust by additonal
> + checks and it can take in UTF-8 string, encoded url with %hex codes.

How many of these checks are already made by idnkit?

> + (e_uri_replace_with_decd_host) Replaces the UTF-8 hostname part of the
> + URI with ACE encoding extra memory if need will be allocated in place.
> +
> + (e_uri_replace_with_encd_host) Replaces the ACE hostname part of the
> + URI with UTF-8 encoding extra memory if need will be allocated in place.

I think these calls are redundant.  The api is weird, not really used
elsehwere in evolution, the code is messy, and it doesn't save much in
all of the callers of the code (and makes some callers code more
complex).

> + (e_uri_gnome_show_idn_url) Call browser with a supplied URL having
> + UTD-8 hostname.

This doesn't match the code, i presume you mean e_uri_show().

Are you sure this is required, shouldn't any encoded url's already be in
encoded format?

> + (replace_str) This static function is used to replace an oldstr
> + at offset oldstr_offset witha newstr, the additional memory needed
> + id allocated within.

Again i think this is overly complex and solving a problem which
doesn't need to be solved.

> + (cache_coded_host) A functions which will store and retrieve
> + ace_name/utf8_name pairs. Used to reduce the overhead in frequent
> + idnkit function calls. Thread safe.

Is this cache really required?  How slow are the idnkit functions?  My
guess is they would be more than fast enough to only use them on
demand.

> + * e-url.h:
> + Added the parameter host_offset to EUri struct. Added
> + e_uri_encode_host, e_uri_decode_host, e_uri_replace_with_decd_host,
> + e_uri_replace_with_encd_host and e_uri_gnome_show_idn_url
> + as new function declarations.

What exactly is host_offset used for?  It seems to be calculated but
never used.


> +e_uri_encode_host (char *utf8_name)
> +{
> +#ifndef ENABLE_IDN
> + if (utf8_name)
> + return (strdup (utf8_name));
> + else
> + return NULL;
> +#else
> + idn_result_t r;
> + char ace_name[256];
> + char *t = NULL, *d = NULL;
> +
> +
> + if (!utf8_name || !strcmp (utf8_name,"")) {
> + return NULL;
> + }
> +
> + t = strdup (utf8_name);
> +
> + uri_decode (t);
> +
> + if (!t && !t[0]) {
> + return  NULL;
> + }
> +
> + if ((d = cache_coded_host (NULL, t)) != NULL) {
> + g_free (t);
> + return d;
> + }
> +
> + r = idn_encodename ( IDN_DELIMMAP | IDN_LOCALMAP | IDN_NAMEPREP | IDN_IDNCONV | IDN_LENCHECK | IDN_ASCCHECK, t, ace_name, sizeof (ace_name));

does LOCALMAP map to local charsets?  Shouldn't it always be utf8?


> + if (r == idn_success) {
> + if (strcmp (ace_name, t))
> + cache_coded_host (ace_name, t);
> + d = strdup(ace_name);
> + }
> +
> + g_free (t);
> +
> + return d;
> +#endif
> +}
> +
> +void
> +e_uri_show (const char *uri_string, GError **err) {
> +#ifndef ENABLE_IDN
> + gnome_url_show (uri_string, err);
> +#else
> + char *t = strdup (uri_string);
> +
> + e_uri_replace_with_encoded_host (&t);
> + gnome_url_show (t, err);
> + g_free (t);
> +#endif
> +}
> +
> +void
> +e_uri_replace_with_encoded_host (char **uri_string)
> +{

> +void
> +e_uri_replace_with_decoded_host (char **uri_string)
> +{

I think these two are just redundant, far too complex and they save
little code in their caller's.

>  EUri *
>  e_uri_copy (EUri *uri)
>  {
> @@ -291,6 +530,7 @@
>  uri_copy->path = g_strdup (uri->path);
>  uri_copy->query = g_strdup (uri->query);
>  uri_copy->fragment = g_strdup (uri->fragment);
> + uri_copy->host_offset = uri->host_offset;

>  /* copy uri->params */
>  g_datalist_foreach (&uri->params,
> Index: e-util/e-url.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/e-util/e-url.h,v
> retrieving revision 1.5
> diff -u -r1.5 e-url.h
> --- e-util/e-url.h 27 Oct 2001 16:59:34 -0000 1.5
> +++ e-util/e-url.h 31 Dec 2003 19:03:09 -0000
> @@ -44,6 +44,7 @@
>  GData *params;
>  char  *query;
>  char  *fragment;
> + int   host_offset;
>  } EUri;

>  EUri       *e_uri_new       (const char *uri_string);
> @@ -51,6 +52,11 @@
>  const char *e_uri_get_param (EUri *uri, const char *name);
>  EUri       *e_uri_copy      (EUri *uri);
>  char       *e_uri_to_string (EUri *uri, gboolean show_password);
> +char    *e_uri_encode_host (char *utf8_name);
> +char    *e_uri_decode_host (char *ace_name);
> +void     e_uri_replace_with_decoded_host (char **uri_string);
> +void     e_uri_replace_with_encoded_host (char **uri_string);
> +void     e_uri_show (const char *uri_string, GError **err);

>  #endif /* __E_URL_H__ */

> Index: mail/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
> retrieving revision 1.2964
> diff -u -r1.2964 ChangeLog
> --- mail/ChangeLog 22 Dec 2003 14:50:56 -0000 1.2964
> +++ mail/ChangeLog 31 Dec 2003 19:03:10 -0000
> @@ -1,3 +1,21 @@
> +2003-12-27  Suresh Chandrasekharan <suresh chandrasekharan sun com>
> +
> + * em-folder-view.c: (emfv_format_link_clicked): When a multibyte
> + hostname is appearing on a URL, convert it into suitable ASCII
> + encoding before passing over to gnome_url_show.
>
doesn't acgtually describe the change.

> + * mail-account-gui.c: (setup_service) Display the mail server name
> + in UTF-8 in account set up windows.
> +
> + * mail-ops.c: (get_folder_desc) Change the output hostname to UTF-8.
> +
> + * mail-send-recv.c: (format_url) hostname in message when the
> + Send/receive button is clicked changed to utf8.
> +
> + * mail-vfolder.c: (vfolder_adduri_desc) Display utf8 host name in
> + 'Updating vfolders for uri' message
> +
> +



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]