From f811846dc5cb6f90a2cc1036088c781f6409bea6 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 13 Aug 2015 19:29:55 +0000 Subject: [PATCH] Allowing to change the file format in restricted mode, but actually disabling Appending, Prepending, making Backups, and opening the File Browser. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5357 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/global.c | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index f07db6b2..0eeace1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ * src/browser.c (browser_init): Speed up the finding of the longest filename: don't limit the value to that of COLS all the time, as this is done later anyway, and don't bother skipping the dot entry. + * src/global.c (shortcut_init): In restricted mode, allow changing + the file format, but actually disable Appending, Prepending, making + Backups, and opening the File Browser. 2015-08-12 Benno Schulenberg * src/chars.c: UTF-8 is a stateless encoding, so there is no need to diff --git a/src/global.c b/src/global.c index 4cc01189..0f6b646b 100644 --- a/src/global.c +++ b/src/global.c @@ -954,19 +954,16 @@ void shortcut_init(void) N_("Go To Text"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW); #ifndef NANO_TINY - /* If we're using restricted mode, the DOS format, Mac format, - * append, prepend, and backup toggles are disabled. The first and - * second are useless since inserting files is disabled, the third - * and fourth are disabled because they allow writing to files not - * specified on the command line, and the fifth is useless since - * backups are disabled. */ + add_to_funcs(dos_format_void, MWRITEFILE, + N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW); + add_to_funcs(mac_format_void, MWRITEFILE, + N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW); + + /* If we're using restricted mode, the Append, Prepend, and Backup toggles + * are disabled. The first and second are not useful as they only allow + * reduplicating the current file, and the third is not allowed as it + * would write to a file not specified on the command line. */ if (!ISSET(RESTRICTED)) { - add_to_funcs(dos_format_void, MWRITEFILE, - N_("DOS Format"), IFSCHELP(nano_dos_msg), TOGETHER, NOVIEW); - - add_to_funcs(mac_format_void, MWRITEFILE, - N_("Mac Format"), IFSCHELP(nano_mac_msg), TOGETHER, NOVIEW); - add_to_funcs(append_void, MWRITEFILE, N_("Append"), IFSCHELP(nano_append_msg), TOGETHER, NOVIEW); add_to_funcs(prepend_void, MWRITEFILE, @@ -1201,14 +1198,17 @@ void shortcut_init(void) #endif add_to_sclist(MWRITEFILE, "M-D", dos_format_void, 0); add_to_sclist(MWRITEFILE, "M-M", mac_format_void, 0); - add_to_sclist(MWRITEFILE, "M-A", append_void, 0); - add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0); - add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0); + if (!ISSET(RESTRICTED)) { + /* Don't allow Appending, Prepending, nor Backups in restricted mode. */ + add_to_sclist(MWRITEFILE, "M-A", append_void, 0); + add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0); + add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0); #ifndef DISABLE_BROWSER - add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0); + add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0); #endif - add_to_sclist(MINSERTFILE|MEXTCMD, "^X", flip_execute_void, 0); - add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0); + add_to_sclist(MINSERTFILE|MEXTCMD, "^X", flip_execute_void, 0); + add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0); + } add_to_sclist(MHELP|MBROWSER, "^C", do_exit, 0); #ifndef DISABLE_HELP add_to_sclist(MHELP, "^G", do_exit, 0); -- 2.39.5