Skip to content

Commit

Permalink
Prevent `epa-file' from encrypting a file double.
Browse files Browse the repository at this point in the history
* twittering-mode.el (twittering-write-and-encrypt): In order to
prevent `epa-file' to encrypt the file double,
`epa-file-name-regexp' is temorarily changed into the null regexp
that never matches any string.
  • Loading branch information
cvmat committed Jun 13, 2010
1 parent 2f5105c commit 24b0df4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Expand Up @@ -10,6 +10,11 @@
(twittering-write-and-encrypt): return t explicitly when it
succeeded in encrypting private information.

* twittering-mode.el (twittering-write-and-encrypt): In order to
prevent `epa-file' to encrypt the file double,
`epa-file-name-regexp' is temorarily changed into the null regexp
that never matches any string.

2010-06-12 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el: Fix bugs.
Expand Down
21 changes: 15 additions & 6 deletions twittering-mode.el
Expand Up @@ -1448,12 +1448,21 @@ like following:
context (cons #'epa-progress-callback-function "Encrypting..."))
(message "Encrypting...")
(condition-case err
(with-temp-file file
(set-buffer-multibyte nil)
(delete-region (point-min) (point-max))
(insert (epg-encrypt-string context str nil))
(message "Encrypting...wrote %s" file)
t)
(unwind-protect
;; In order to prevent `epa-file' to encrypt the file double,
;; `epa-file-name-regexp' is temorarily changed into the null
;; regexp that never matches any string.
(let ((epa-file-name-regexp "\\`\\'"))
(when (fboundp 'epa-file-name-regexp-update)
(epa-file-name-regexp-update))
(with-temp-file file
(set-buffer-multibyte nil)
(delete-region (point-min) (point-max))
(insert (epg-encrypt-string context str nil))
(message "Encrypting...wrote %s" file)
t))
(when (fboundp 'epa-file-name-regexp-update)
(epa-file-name-regexp-update)))
(error
(message "%s" (cdr err))
nil))))
Expand Down

0 comments on commit 24b0df4

Please sign in to comment.