diff options
author | Pierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk> | 2009-08-28 22:49:07 +0800 |
---|---|---|
committer | Pierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk> | 2009-08-29 01:02:16 +0800 |
commit | 74a34883df84726ad94359675f3c65a624619dc9 (patch) | |
tree | 835a0969941b42f5172ccbfed4a042099b430b9b /libempathy-gtk | |
parent | e388248780b01e51a5a1515cefc0240064620e74 (diff) | |
download | gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.tar gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.tar.gz gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.tar.bz2 gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.tar.lz gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.tar.xz gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.tar.zst gsoc2013-empathy-74a34883df84726ad94359675f3c65a624619dc9.zip |
Add empathy_make_absolute_url_len to limit the lenght of url string
Related to http://bugzilla.gnome.org/show_bug.cgi?id=593207
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 37 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 2 |
3 files changed, 28 insertions, 13 deletions
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index f557d07bb..d7fd01729 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -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); diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index c12cbd1c9..3089c46ea 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -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 diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index afb409af4..39baeaf41 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -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 |