This is an automated email from the git hooks/post-receive script. hjudt pushed a commit to branch master in repository xfce/thunar.
commit b385bcf7c856fdc0a63b5f91a6d4053a7d22347e Author: Harald Judt <h.j...@gmx.at> Date: Fri Feb 27 22:26:09 2015 +0100 Improve check for shell scripts and add hidden option for bug #7596 The check for shell scripts was incomplete. This commit extends it to all executable scripts that are text/plain. For people wanting the old, unsafe behaviour there is a new boolean option called "misc-exec-shell-scripts-by-default" that can be created and set to TRUE using xfconf-query or the Xfce settings editor. --- thunar/thunar-file.c | 34 +++++++++++++++++++--------------- thunar/thunar-preferences.c | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index e254347..9b5aa9b 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -63,6 +63,7 @@ #include <thunar/thunar-gio-extensions.h> #include <thunar/thunar-gobject-extensions.h> #include <thunar/thunar-private.h> +#include <thunar/thunar-preferences.h> #include <thunar/thunar-user.h> #include <thunar/thunar-util.h> #include <thunar/thunar-dialogs.h> @@ -2755,8 +2756,10 @@ thunar_file_is_ancestor (const ThunarFile *file, gboolean thunar_file_is_executable (const ThunarFile *file) { - gboolean can_execute = FALSE; - const gchar *content_type; + ThunarPreferences *preferences; + gboolean can_execute = FALSE; + gboolean exec_shell_scripts = FALSE; + const gchar *content_type; _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); @@ -2769,20 +2772,21 @@ thunar_file_is_executable (const ThunarFile *file) content_type = thunar_file_get_content_type (THUNAR_FILE (file)); if (G_LIKELY (content_type != NULL)) { -#ifdef G_OS_WIN32 - /* check for .exe, .bar or .com */ can_execute = g_content_type_can_be_executable (content_type); -#else - /* Check if the content type is safe to execute, we don't - * use g_content_type_can_be_executable() for unix because - * it also returns true for "text/plain" and we don't want - * that. Also do not execute x-shellscripts by default, it - * is safer to open them in an editor or run them in a - * terminal, usually they require parameters. */ - if (g_content_type_is_a (content_type, "application/x-executable") - && ! g_content_type_is_a (content_type, "application/x-shellscript")) - can_execute = TRUE; -#endif + + if (can_execute) + { + /* check if the shell scripts should be executed or opened by default */ + preferences = thunar_preferences_get (); + g_object_get (preferences, "misc-exec-shell-scripts-by-default", &exec_shell_scripts, NULL); + g_object_unref (preferences); + + /* do never execute plain text files which are not shell scripts but marked executable */ + if (g_strcmp0 (content_type, "text/plain") == 0) + can_execute = FALSE; + else if (g_content_type_is_a (content_type, "text/plain") && ! exec_shell_scripts) + can_execute = FALSE; + } } } diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c index 684485f..9a86ae1 100644 --- a/thunar/thunar-preferences.c +++ b/thunar/thunar-preferences.c @@ -75,6 +75,7 @@ enum PROP_MISC_VOLUME_MANAGEMENT, PROP_MISC_CASE_SENSITIVE, PROP_MISC_DATE_STYLE, + PROP_EXEC_SHELL_SCRIPTS_BY_DEFAULT, PROP_MISC_FOLDERS_FIRST, PROP_MISC_FULL_PATH_IN_TITLE, PROP_MISC_HORIZONTAL_WHEEL_NAVIGATES, @@ -492,6 +493,22 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass) EXO_PARAM_READWRITE); /** + * ThunarPreferences:misc-execute-shell-scripts-by-default: + * + * Shell scripts are often unsafe to execute, require additional + * parameters and most users will only want to edit them in their + * favorite editor, so the default is to open them in the associated + * application. Setting this to TRUE allows executing them, like + * binaries, by default. See bug #7596. + **/ + preferences_props[PROP_EXEC_SHELL_SCRIPTS_BY_DEFAULT] = + g_param_spec_boolean ("misc-exec-shell-scripts-by-default", + "MiscExecShellScriptsByDefault", + NULL, + FALSE, + EXO_PARAM_READWRITE); + + /** * ThunarPreferences:misc-folders-first: * * Whether to sort folders before files. -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits