jamessan / vim-gnupg

This script implements transparent editing of gpg encrypted files.
http://www.vim.org/scripts/script.php?script_id=3645
724 stars 72 forks source link

GPGEditOptions Broken ? #89

Closed FractalWire closed 6 years ago

FractalWire commented 6 years ago

Hi,

I have an issue with GPGEditOptions. When I called it and then save it, I got an error saying something like :

The recipient "encrypt" is not in your public keyring ! The recipient "armor" is not in your public keyring !

If I try to save the file, I've got a warning stating I have to edit GPGEditRecipients, which give a content similar to that :

GPG: Please edit the list of recipients, one recipient per line. GPG: Unknown recipients have a prepended "!". GPG: Lines beginning with "GPG:" are removed automatically. GPG: Data after recipients between and including "(" and ")" is ignored. GPG: Closing this buffer commits changes. GPG: ---------------------------------------------------------------------- myname mail@mail.com (ID: 0xC1BDCB497E0B9CD6 created at mar. 10 avril 2018 19:40:18 CEST) GPG: ---------------------------------------------------------------------- GPG: Please edit the list of recipients, one recipient per line. GPG: Unknown recipients have a prepended "!". GPG: Lines beginning with "GPG:" are removed automatically. GPG: Data after recipients between and including "(" and ")" is ignored. GPG: Closing this buffer commits changes. GPG: ---------------------------------------------------------------------- myname mail@mail.com (ID: 0xC1BDCB497E0B9CD6 created at mar. 10 avril 2018 19:40:18 CEST) !encrypt !armor

So, somehow, GPGEditOptions and GPGEditRecipients might be mixed up...

jamessan commented 6 years ago

Can you give some more concrete steps, please? Especially regarding the contents of the GPGEditOptions buffer.

FractalWire commented 6 years ago

Hi sorry for the late answer. Yes I was a bit lazy when I report the issue.

So here is the full steps :

1) Create a file test.asc 2) save and exit 3) edit the file again and invoke GPGEditOptions. It gives something like that :

GPG: Please edit the list of recipients, one recipient per line.
GPG: Unknown recipients have a prepended "!".
GPG: Lines beginning with "GPG:" are removed automatically.
GPG: Data after recipients between and including "(" and ")" is ignored.
GPG: Closing this buffer commits changes.
GPG: ----------------------------------------------------------------------
myname <mail@mymail.com>        (ID: 0xC1BDCB497E0B9CD6 created at mar. 10 avril 2018 19:40:18 CEST)
GPG: ----------------------------------------------------------------------
GPG: THERE IS NO CHECK OF THE ENTERED OPTIONS!
GPG: YOU NEED TO KNOW WHAT YOU ARE DOING!
GPG: IF IN DOUBT, QUICKLY EXIT USING :x OR :bd.
GPG: Please edit the list of options, one option per line.
GPG: Please refer to the gpg documentation for valid options.
GPG: Lines beginning with "GPG:" are removed automatically.
GPG: Closing this buffer commits changes.
GPG: ----------------------------------------------------------------------
encrypt
armor

Both, the recipient and the options are present in the buffer.

4) Without modifying anything, I try to save and close the buffer and I've got the following error :

The recipient "encrypt" is not in your public keyring !
The recipient "armor" is not in your public keyring !

5) I now have 2 buffers opens :

9) now I clean up a bit, living only one `myname <mail@mymail.com>` with its commentary, and I save and close the buffer
10) I've now got 2 buffer : 
- 1 empty buffer named GPGRecipients_PathToMyFile.asc (that need to be saved)
- my original GPG file
11) So I save and close the empty buffer
12) Finally, when trying to save and close my GPG file I've got the following error : 

/bin/sh: -c: line 0: syntax error near unexpected token (' Message could not be encrypted! (Press ENTER) ')



And I'm forced to close without saving now.
Joedang commented 6 years ago

I think I'm experiencing the same/similar error. AFAICT, it's happening when we try to edit the options buffer.

Here's what I think may help...

This is where I think we're either getting confused or experiencing a bug.

Now, if I try something different...

So, maybe I don't understand how buffers are supposed to work, and quitting is the wrong thing to do. But, it seems like the plugin shouldn't be doing this. As long as the recipients and options are in the state they should be, the files save and open as I'd expect. But changing them really sucks because of this.

jamessan commented 6 years ago

Thanks for the report! This should be fixed now.