]> www.fi.muni.cz Git - evince.git/commitdiff
Check whether uri is valid before launching it. Fixes bug #427664.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 19 Apr 2007 14:53:19 +0000 (14:53 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Thu, 19 Apr 2007 14:53:19 +0000 (14:53 +0000)
2007-04-19  Carlos Garcia Campos  <carlosgc@gnome.org>
* shell/ev-window.c: (uri_is_valid), (launch_external_uri):
Check whether uri is valid before launching it. Fixes bug #427664.

svn path=/trunk/; revision=2409

ChangeLog
shell/ev-window.c

index d27afefa163cf138a497671ff4a7c1dfb0bbbeab..9198d0dde1f24033b2b88d7ec009979e3e284ad1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-19  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-window.c: (uri_is_valid), (launch_external_uri):
+
+       Check whether uri is valid before launching it. Fixes bug #427664.
+
 2007-04-19  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-window.c:
index 7863c28cf36592edb14fa6b8c06df214190ffcb1..4d76b6f2925b72be8e01a35ceddac18932f633ad 100644 (file)
@@ -4516,10 +4516,45 @@ launch_action (EvWindow *window, EvLinkAction *action)
           allowing to launch executables is a good idea though. -- marco */
 }
 
+static gboolean
+uri_is_valid (const gchar *uri)
+{
+       gchar *p = (gchar *) uri;
+       
+       if (!p || !g_ascii_isalpha (*p))
+               return FALSE;
+       
+       p++;
+       while (g_ascii_isalnum (*p))
+               p++;
+
+       return (g_ascii_strncasecmp (p, "://", strlen ("://")) == 0);
+}
+
 static void
 launch_external_uri (EvWindow *window, EvLinkAction *action)
 {
-       gnome_vfs_url_show (ev_link_action_get_uri (action));
+       const gchar *uri = ev_link_action_get_uri (action);
+       
+       if (!uri_is_valid (uri)) {
+               GtkWidget *dialog;
+
+               dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                                GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                GTK_MESSAGE_ERROR,
+                                                GTK_BUTTONS_CLOSE,
+                                                _("Unable to open external link"));
+               gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                                         _("Invalid URI: ā€œ%sā€"), uri);
+               g_signal_connect (dialog, "response",
+                                 G_CALLBACK (gtk_widget_destroy),
+                                 NULL);
+               gtk_widget_show (dialog);
+
+               return;
+       }
+       
+       gnome_vfs_url_show (uri);
 }
 
 static void