forked from mirrors/org-mode
org-crypt: Fix data loss when providing an empty key
* lisp/org-crypt.el (org-encrypt-entry): Insert original text back upon encryption failure. Reported-by: fxiny <wtimew@libero.it> <http://permalink.gmane.org/gmane.emacs.orgmode/111115>
This commit is contained in:
parent
dff9cf9c80
commit
dd727cf0cb
|
@ -183,7 +183,11 @@ See `org-crypt-disable-auto-save'."
|
|||
(org-end-of-subtree t t)
|
||||
(org-back-over-empty-lines)
|
||||
(let ((contents (delete-and-extract-region beg (point))))
|
||||
(insert (org-encrypt-string contents crypt-key)))
|
||||
(condition-case err
|
||||
(insert (org-encrypt-string contents crypt-key))
|
||||
;; If encryption failed, make sure to insert back entry
|
||||
;; contents in the buffer.
|
||||
(error (insert contents) (error (nth 1 err)))))
|
||||
(when folded
|
||||
(goto-char start-heading)
|
||||
(outline-hide-subtree))
|
||||
|
|
Loading…
Reference in New Issue