On Do, 15 Aug 2013, Bram Moolenaar wrote:
> Christian Brabandt wrote:
> > Wouldn't it be a good idea, to have the file set readonly for as long it
> > hasn't been encrypted (e.g. the current windows behaviour)?
>
> You mean, until it has been decrypted. That makes sense.
> Actually, when a file is encrypted and the user just hits enter and the
> prompt for the key, it should also be marked as readonly.
Err, yes that was what I meant.
I think this patch does it:
iff --git a/src/fileio.c b/src/fileio.c
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2926,9 +2926,15 @@
int *did_ask; /* flag: whether already asked for key
*/
{
int method = crypt_method_from_magic((char *)ptr, *sizep);
+ int b_p_ro = curbuf->b_p_ro;
if (method >= 0)
{
+ /* prevent nasty side-effects by e.g.
+ * FocusLeave autocommands, trying to write the file
+ * or the user accidently hitting enter on the password
+ * prompt and accidently writing the file */
+ curbuf->b_p_ro = TRUE;
set_crypt_method(curbuf, method);
if (method > 0)
(void)blowfish_self_test();
@@ -2977,6 +2983,7 @@
*sizep -= CRYPT_MAGIC_LEN + salt_len + seed_len;
mch_memmove(ptr, ptr + CRYPT_MAGIC_LEN + salt_len + seed_len,
(size_t)*sizep);
+ curbuf->b_p_ro = b_p_ro; /* resetting ro flag */
}
}
/* When starting to edit a new file which does not have encryption, clear
regards,
Christian
--
Wenn du etwas Glück dein Eigen nennst, verheimliche es.
-- Saul Bellow
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.