aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-ui-utils.c
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-08-28 22:49:07 +0800
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-08-29 01:02:16 +0800
commit74a34883df84726ad94359675f3c65a624619dc9 (patch)
tree835a0969941b42f5172ccbfed4a042099b430b9b /libempathy-gtk/empathy-ui-utils.c
parente388248780b01e51a5a1515cefc0240064620e74 (diff)
downloadgsoc2013-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/empathy-ui-utils.c')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c37
1 files changed, 25 insertions, 12 deletions
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