diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2009-03-03 17:46:50 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-03-03 17:46:50 +0800 |
commit | ba7eae326c9cd3e12447bf636cedfae6284b2581 (patch) | |
tree | 25d1aec934c513dc6165b59fb7d6a8430713c319 /libempathy-gtk/empathy-ui-utils.c | |
parent | 02c2e9960f1a66ed3661e67f1038a6aeea7a2d69 (diff) | |
download | gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.gz gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.bz2 gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.lz gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.xz gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.tar.zst gsoc2013-empathy-ba7eae326c9cd3e12447bf636cedfae6284b2581.zip |
Move URI regex to empathy-ui-utils
From: Xavier Claessens <xclaesse@gmail.com>
svn path=/trunk/; revision=2549
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 692b6ff7d..9e8928e8e 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -53,6 +53,14 @@ #include <libempathy/empathy-idle.h> #include <libempathy/empathy-tp-file.h> +#define SCHEMES "(https?|s?ftps?|nntp|news|javascript|about|ghelp|apt|telnet|"\ + "file|webcal|mailto)" +#define BODY "([^\\ \\n]+)" +#define END_BODY "([^\\ \\n]*[^,;\?><()\\ \"\\.\\n])" +#define URI_REGEX "("SCHEMES"://"END_BODY")" \ + "|((mailto:)?"BODY"@"BODY"\\."END_BODY")"\ + "|((www|ftp)\\."END_BODY")" + void empathy_gtk_init (void) { @@ -68,6 +76,19 @@ empathy_gtk_init (void) initialized = TRUE; } +GRegex * +empathy_uri_regex_dup_singleton (void) +{ + static GRegex *uri_regex = NULL; + + /* We intentionally leak the regex so it's not recomputed */ + if (!uri_regex) { + uri_regex = g_regex_new (URI_REGEX, 0, 0, NULL); + } + + return g_regex_ref (uri_regex); +} + struct SizeData { gint width; gint height; |