X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b35f288d478ef137a4d9e8e5a6a5f368a86b01f5..b336bfcdf39f1e4d35bff4a7bd01d3b4bca8f516:/lisp/epa-file.el diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 25edba5a2d..2bbb0aa645 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -1,5 +1,5 @@ ;;; epa-file.el --- the EasyPG Assistant, transparent file encryption -;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Daiki Ueno ;; Keywords: PGP, GnuPG @@ -25,7 +25,12 @@ (require 'epa-hook) (defcustom epa-file-cache-passphrase-for-symmetric-encryption nil - "If non-nil, cache passphrase for symmetric encryption." + "If non-nil, cache passphrase for symmetric encryption. + +For security reasons, this option is turned off by default and +not recommended to use. Instead, consider using public-key +encryption with gpg-agent which does the same job in a safer +way." :type 'boolean :group 'epa-file) @@ -86,14 +91,13 @@ (if (fboundp 'decode-coding-inserted-region) (save-restriction (narrow-to-region (point) (point)) - (let ((multibyte enable-multibyte-characters)) - (set-buffer-multibyte nil) - (insert string) - (set-buffer-multibyte multibyte) + (insert (if enable-multibyte-characters + (string-to-multibyte string) + string)) (decode-coding-inserted-region (point-min) (point-max) (substring file 0 (string-match epa-file-name-regexp file)) - visit beg end replace))) + visit beg end replace)) (insert (epa-file--decode-coding-string string (or coding-system-for-read 'undecided))))) @@ -104,7 +108,7 @@ (error "Attempt to visit less than an entire file")) (setq file (expand-file-name file)) (let* ((local-copy - (condition-case inl + (condition-case nil (epa-file-run-real-handler #'file-local-copy (list file)) (error))) (local-file (or local-copy file)) @@ -140,7 +144,9 @@ (epa-file-decode-and-insert string file visit beg end replace) (setq length (- (point-max) (point-min)))) (if replace - (delete-region (point) (point-max))))) + (delete-region (point) (point-max))) + (if visit + (set-visited-file-modtime)))) (if (and local-copy (file-exists-p local-copy)) (delete-file local-copy))) @@ -150,7 +156,7 @@ (defun epa-file-write-region (start end file &optional append visit lockname mustbenew) (if append - (error "Can't append to the file.")) + (error "Can't append to the file")) (setq file (expand-file-name file)) (let* ((coding-system (or coding-system-for-write (if (fboundp 'select-safe-coding-system) @@ -182,6 +188,9 @@ context (if (stringp start) (epa-file--encode-coding-string start coding-system) + (unless start + (setq start (point-min) + end (point-max))) (epa-file--encode-coding-string (buffer-substring start end) coding-system)) (if (or epa-file-select-keys