diff options
Diffstat (limited to 'lib/ephy-dnd.c')
-rw-r--r-- | lib/ephy-dnd.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c index 03fa83544..99438495c 100644 --- a/lib/ephy-dnd.c +++ b/lib/ephy-dnd.c @@ -20,6 +20,7 @@ #include <gtk/gtkselection.h> #include <gtk/gtktreeview.h> +#include <string.h> static GtkTargetEntry url_drag_types [] = { @@ -108,3 +109,52 @@ ephy_dnd_enable_model_drag_source (GtkWidget *treeview) GDK_ACTION_COPY); } +GList * +ephy_dnd_uri_list_extract_uris (const char *uri_list) +{ + /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */ + + const gchar *p, *q; + gchar *retval; + GList *result = NULL; + + g_return_val_if_fail (uri_list != NULL, NULL); + + p = uri_list; + + /* We don't actually try to validate the URI according to RFC + * 2396, or even check for allowed characters - we just ignore + * comments and trim whitespace off the ends. We also + * allow LF delimination as well as the specified CRLF. + */ + while (p != NULL) { + if (*p != '#') { + while (g_ascii_isspace (*p)) + p++; + + q = p; + while ((*q != '\0') + && (*q != '\n') + && (*q != '\r')) + q++; + + if (q > p) { + q--; + while (q > p + && g_ascii_isspace (*q)) + q--; + + retval = g_malloc (q - p + 2); + strncpy (retval, p, q - p + 1); + retval[q - p + 1] = '\0'; + + result = g_list_prepend (result, retval); + } + } + p = strchr (p, '\n'); + if (p != NULL) + p++; + } + + return g_list_reverse (result); +} |