]> git.0d.be Git - empathy.git/commitdiff
Add empathy_make_absolute_url_len to limit the lenght of url string
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
Fri, 28 Aug 2009 14:49:07 +0000 (10:49 -0400)
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
Fri, 28 Aug 2009 17:02:16 +0000 (13:02 -0400)
Related to http://bugzilla.gnome.org/show_bug.cgi?id=593207

libempathy-gtk/empathy-theme-adium.c
libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h

index f557d07bb49fd611c97b20d5bab33e606f98927f..d7fd01729b9f3bc09523a7061210b7df7b5c56fb 100644 (file)
@@ -328,7 +328,7 @@ theme_adium_parse_body (EmpathyThemeAdium *theme,
                        }
 
                        /* Append the link inside <a href=""></a> tag */
-                       real_url = empathy_make_absolute_url (text + s);
+                       real_url = empathy_make_absolute_url_len (text + s, e - s);
 
                        g_string_append (string, "<a href=\"");
                        g_string_append (string, real_url);
index c12cbd1c9ce31c783ce8f9a7f373e30d74f0b183..3089c46eae091927fd1251846253e287671d2123 100644 (file)
@@ -1321,33 +1321,46 @@ empathy_get_toplevel_window (GtkWidget *widget)
        return NULL;
 }
 
-/** empathy_make_absolute_url:
+/** empathy_make_absolute_url_len:
  * @url: an url
+ * @len: a length
  *
- * The URL opening code can't handle schemeless strings, so we try to be
- * smart and add http if there is no scheme or doesn't look like a mail
- * address. This should work in most cases, and let us click on strings
- * like "www.gnome.org".
- *
- * Returns: a newly allocated url with proper mailto: or http:// prefix, use
- * g_free when your are done with it
+ * Same as #empathy_make_absolute_url but for a limited string length
  */
 gchar *
-empathy_make_absolute_url (const gchar *url)
+empathy_make_absolute_url_len (const gchar *url,
+                              guint len)
 {
        g_return_val_if_fail (url != NULL, NULL);
 
        if (g_str_has_prefix (url, "ghelp:") ||
            g_str_has_prefix (url, "mailto:") ||
            strstr (url, ":/")) {
-               return g_strdup (url);
+               return g_strndup (url, len);
        }
 
        if (strstr (url, "@")) {
-               return g_strdup_printf ("mailto:%s", url);
+               return g_strdup_printf ("mailto:%.*s", len, url);
        }
 
-       return g_strdup_printf ("http://%s", url);
+       return g_strdup_printf ("http://%.*s", len, url);
+}
+
+/** empathy_make_absolute_url:
+ * @url: an url
+ *
+ * The URL opening code can't handle schemeless strings, so we try to be
+ * smart and add http if there is no scheme or doesn't look like a mail
+ * address. This should work in most cases, and let us click on strings
+ * like "www.gnome.org".
+ *
+ * Returns: a newly allocated url with proper mailto: or http:// prefix, use
+ * g_free when your are done with it
+ */
+gchar *
+empathy_make_absolute_url (const gchar *url)
+{
+       return empathy_make_absolute_url_len (url, strlen (url));
 }
 
 void
index afb409af430b1115a5119fe2a4526bb0046d8d5f..39baeaf41e28321b16524b9a93dd598adac60839 100644 (file)
@@ -110,6 +110,8 @@ void        empathy_send_file_with_file_chooser         (EmpathyContact   *conta
 void        empathy_receive_file_with_file_chooser      (EmpathyFTHandler *handler);
 
 gchar *     empathy_make_absolute_url                   (const gchar *url);
+gchar *     empathy_make_absolute_url_len               (const gchar *url,
+                                                        guint len);
 
 G_END_DECLS