aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-theme-adium.c2
-rw-r--r--libempathy-gtk/empathy-ui-utils.c37
-rw-r--r--libempathy-gtk/empathy-ui-utils.h2
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