commit f811846dc5cb6f90a2cc1036088c781f6409bea6
parent 8a058d1f9a335a8422653b81b8dced77f5e90154
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 13 Aug 2015 19:29:55 +0000
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
Diffstat:
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git 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 <bensberg@justemail.net>
* 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
@@ -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);