[Xfce4-commits] <xfce-utils:xfce-4.8> Only try a selection of strings in exo-open (bug #7200).
Nick Schermer
noreply at xfce.org
Fri Jun 17 23:28:07 CEST 2011
Updating branch refs/heads/xfce-4.8
to 3bfa11aa7fb805286c5b6cfb633cdb28192baccc (commit)
from 5340db70c42e5a9c577c2f54fda9b9d6ff2c9697 (commit)
commit 3bfa11aa7fb805286c5b6cfb633cdb28192baccc
Author: Nick Schermer <nick at xfce.org>
Date: Fri Jun 17 19:59:40 2011 +0200
Only try a selection of strings in exo-open (bug #7200).
Only to strings that look like uris, paths, www or email
addresses in exo-open.
(cherry picked from commit 008a2e323998478a275e31b0eb5aeeab9ec761bc)
xfrun/xfrun-dialog.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/xfrun/xfrun-dialog.c b/xfrun/xfrun-dialog.c
index cb14011..c7f83ef 100644
--- a/xfrun/xfrun-dialog.c
+++ b/xfrun/xfrun-dialog.c
@@ -470,6 +470,24 @@ xfrun_add_to_history(const gchar *command,
g_strfreev(lines);
}
+static gboolean
+exo_str_looks_like_an_uri (const gchar *str)
+{
+ const gchar *s = str;
+
+ /* <scheme> starts with an alpha character */
+ if (g_ascii_isalpha (*s))
+ {
+ /* <scheme> continues with (alpha | digit | "+" | "-" | ".")* */
+ for (++s; g_ascii_isalnum (*s) || *s == '+' || *s == '-' || *s == '.'; ++s);
+
+ /* <scheme> must be followed by ":" */
+ return (*s == ':');
+ }
+
+ return FALSE;
+}
+
static void
xfrun_spawn_child_setup(gpointer data)
{
@@ -542,7 +560,11 @@ xfrun_run_clicked(GtkWidget *widget,
gchar *primary;
gboolean exo_opened = FALSE;
- if(!in_terminal) {
+ if(!in_terminal
+ && (exo_str_looks_like_an_uri (cmdline)
+ || g_path_is_absolute (cmdline)
+ || g_str_has_prefix (cmdline, "www.")
+ || strstr (cmdline, "@") != NULL)) {
/* Try to open with exo-open (for files, folders, uris...) */
gchar **exo_argv = NULL;
const gchar *exo_open;
@@ -581,7 +603,7 @@ xfrun_run_clicked(GtkWidget *widget,
if(error)
g_error_free(error);
}
- }else {
+ } else {
primary = g_strdup_printf(_("The command \"%s\" failed to run:"),
cmdline);
xfce_message_dialog(GTK_WINDOW(dialog), _("Run Error"),
More information about the Xfce4-commits
mailing list