[Telepathy-commits] [telepathy-sofiasip/master] Lowercase the URL schema

Mikhail Zabaluev mikhail.zabaluev at nokia.com
Wed Oct 8 08:45:09 PDT 2008


---
 src/sip-connection-helpers.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/sip-connection-helpers.c b/src/sip-connection-helpers.c
index 5b29674..ffbd013 100644
--- a/src/sip-connection-helpers.c
+++ b/src/sip-connection-helpers.c
@@ -728,6 +728,36 @@ priv_strip_tel_num (const gchar *fuzzy)
   return g_regex_replace_literal (cruft_regex, fuzzy, -1, 0, "", 0, NULL);
 }
 
+static const char *
+priv_lowercase_url_part (su_home_t *home, const char *src)
+{
+  size_t n = 0;
+  size_t i;
+  gboolean needs_lowercasing = FALSE;
+  char *res;
+
+  while (src[n])
+    {
+      if (g_ascii_isupper (src[n]))
+        {
+          needs_lowercasing = TRUE;
+          n += strlen (src + n);
+          break;
+        }
+      ++n;
+    }
+
+  if (!needs_lowercasing)
+    return src;
+
+  res = su_alloc (home, n + 1);
+  for (i = 0; i < n; i++)
+    res[i] = g_ascii_tolower (src[i]);
+  res[i] = '\0';
+
+  return (const char *) res;
+}
+
 #define TPSIP_RESERVED_CHARS_ALLOWED_IN_USERNAME "!*'()&=+$,;?/"
 
 gchar *
@@ -783,6 +813,11 @@ tpsip_handle_normalize (TpHandleRepoIface *repo,
   if (url->url_scheme == NULL || (url->url_scheme[0] == 0))
     goto error;
 
+  /* convert the scheme to lowercase */
+  /* Note: we can't do it in place because url->url_scheme may point to
+   * a static string */
+  url->url_scheme = priv_lowercase_url_part (home, url->url_scheme);
+
   /* Check that if we have '@', the username isn't empty.
    * Note that we rely on Sofia-SIP to canonize the user name */
   if (url->url_user)
-- 
1.5.6.5




More information about the Telepathy-commits mailing list