Permalink
Commits on Feb 15, 2017
  1. Set "buftype=acwrite" for encrypted buffers

    This ensures any write of the buffer requires a configured BufWriteCmd
    autocmd, providing more safe guards against problems like
    jamessan/vim-gnupg#77.
    
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Feb 15, 2017
  2. Remove GPGCleanup function

    If 'autowrite' is set, an encrypted buffer is modified, and ":q!"/"ZQ"
    is executed, GPGCleanup's "only!" would cause the buffer to be
    abandoned.  Due to 'autowrite' and the VimLeave autocmd not using
    "nested", abandoning the buffer causes Vim to write the buffer, which is
    currently unencrypted, overwriting the encrypted file with plain text.
    
    Since the user can more reliably clear their own console/terminal scroll
    back than we can, simply remove this functionality.  It's safer than
    trying to unwind the twisty passages of Vim's autocmds, especially those
    of the *WriteCmd variety.
    
    Closes jamessan/vim-gnupg#77
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Feb 15, 2017
Commits on Dec 18, 2016
  1. Use non-fnameescape()d filenames in logs

    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Dec 18, 2016
  2. GPGDecrypt: Handle (un)encrypted files consistently

    In the refactor to use the *Cmd events, an unencrypted file was simply
    :read into the buffer.  This incorrectly caused an extra blank line to
    be added to the top of the buffer.
    
    The handling of encrypted files properly handles this, as well as
    triggering BufRead(Pre,Post) events.
    
    Instead of returning early for unencrypted files, go through the same
    steps as for encrypted files (minus the encryption specific steps), thus
    preserving the content of the original file.
    committed Dec 18, 2016
  3. Add s:unencrypted function to consolidate "unencrypted buffer" check

    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Dec 18, 2016
  4. GPGCleanup: Use "only!" to force hiding modified buffers

    In dda14ab, GPGCleanup added 'set
    buffhidden=hide' to try avoiding error messages when modified buffers
    are being abandoned.  However, that only works if the buffer is the last
    visible buffer.
    
    If there are windows displaying multiple buffers, then errors can still
    be emitted.  Using "only!" ensures all the other windows can be closed.
    
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Dec 18, 2016
Commits on Dec 15, 2016
  1. GPGCleanup: Allow the buffer to be hidden on exit

    When Vim has decided it can exit, GPGCleanup forces a blank buffer to
    take over the screen so contents aren't visible in scrollback.  However,
    if the buffer is modified and 'hidden' isn't set then the command will
    fail.
    
    Force the buffer to be hidden, so this is avoided.
    
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Dec 15, 2016
Commits on Dec 4, 2016
  1. GPGEdit{Recipients,Options}: Check for presence of b:GPGCorrespondingTo

    Since the user can control which file patterns are handled by the plugin
    (via g:GPGFilePattern), the regular expression checking the buffer name
    for GPGEdit{Recipients,Options} may not match.  A simpler and more
    definitive check is to see whether b:GPGCorrespondingTo is set to
    determine if the buffer is an existing recipients/options buffer.
    
    Closes jamessan/vim-gnupg#72
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Dec 4, 2016
Commits on Sep 18, 2016
  1. GPGEncrypt: Remove (file)encoding dance around file encryption

    Changing &encoding when &fileencoding != &encoding causes two problems.
    
    First, it's completely unsafe to change &encoding after vim is running,
    since there may be characters that can't be translated from one encoding
    to another, which can make vim crash.
    
    Second, this actually loses information about the buffer's encoding.
    When the encrypted file is opened later, it won't be in the same
    encoding as before it was saved.  Changing user's data on them is
    unacceptable.
    
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Sep 18, 2016
  2. Use “:read ++edit !...” so file encoding/format detection triggers

    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Sep 18, 2016
Commits on Aug 26, 2016
  1. Maintain 'readonly' if it's already set

    If the user is using "vim -R"/":view", then the opened buffer should
    have 'readonly' set, even if permissions would otherwise allow editing.
    
    Closes jamessan/vim-gnupg#67
    
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Aug 26, 2016
Commits on Apr 25, 2016
  1. Stop setting g:GPGPreferArmor in GPGInit

    When the user hasn't explicity let g:GPGPreferArmor, the value is
    supposed to be determined by the filename.  Instead of letting
    g:GPGPreferArmor, lazily determine what should be done when actually
    doing the encryption.
    
    Signed-off-by: James McCoy <jamessan@jamessan.com>
    committed Apr 25, 2016
Commits on Dec 18, 2015
  1. Handle rename() failures

    Renaming the temporary, encrypted file to the intended filename (per the
    buffer) may fail (e.g., typoed directory name).  In this case, remove
    the temporary file and then give the typical error message for this
    situation.
    
    In order to be safe, the message is manually being generated instead of
    trying to be clever and do something like “noautocmd write” expecting it
    to hit the same error that rename() did.
    
    Closes jamessan/vim-gnupg#56
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Dec 18, 2015
Commits on Dec 12, 2015
  1. Fall back to `gpg2` if `gpg` is not available

    Signed-off-by: James McCoy <vega.james@gmail.com>
    srstevenson committed with Dec 11, 2015
Commits on Dec 5, 2015
  1. Explain X selection problem in Known Issues

    Closes jamessan/vim-gnupg#36
    
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Dec 5, 2015
Commits on Nov 5, 2015
  1. After writing the buffer to disk, update 'readonly'

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Nov 5, 2015
  2. Ignore hidden recipients when decrypting

    When --throw-keyids, --hidden-recipient, or --hidden-encrypt-to were
    used for an encrypted file, the encryption metadata uses all zeroes as
    the key ID.  Ignore these key IDs to avoid generating extraneous
    messages during decryption or adding invalid IDs to the recipients list.
    
    Closes jamessan/vim-gnupg#50
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Nov 5, 2015
  3. Set 'readonly' per the permissions of the encrypted file.

    Closes jamessan/vim-gnupg#51
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Nov 5, 2015
Commits on Oct 6, 2015
  1. remove unnecessary exists check for g:GPGPreferSymmetric

    The variable is always set in GPGInit().
    
    Signed-off-by: James McCoy <vega.james@gmail.com>
    rudis committed with Oct 3, 2015
  2. remove superfluous | in BufReadCmd autocmd

    Signed-off-by: James McCoy <vega.james@gmail.com>
    rudis committed with Oct 3, 2015
  3. use variable for fnameescape(expand('<afile>:r'))

    Signed-off-by: James McCoy <vega.james@gmail.com>
    rudis committed with Oct 3, 2015
  4. use .= where possible

    Signed-off-by: James McCoy <vega.james@gmail.com>
    rudis committed with Oct 3, 2015
  5. update documentation to match code, add missing defaults

    Signed-off-by: James McCoy <vega.james@gmail.com>
    rudis committed with Oct 3, 2015
Commits on Sep 29, 2015
  1. Account for 'shellslash' being set on Windows

    If a user has 'shellslash' set in Windows, then filename related
    functionality uses forward slashes instead of backslashes.  This breaks
    running of external commands because some external commands in Windows
    treat any forward slash as a command line switch.
    
    This change adds s:shellescape(), which wraps Vim's shellescape(), but
    ensures 'noshellslash' is set first in Windows command prompt (not
    Cygwin or msys) environments.  Having 'noshellslash' set when
    shellescape() is called causes the string to be quoted, regardless of
    whether there is whitespace or typical special characters, thus avoiding
    the interpretation of the string as being command line switches.
    
    Closes jamessan/vim-gnupg#41
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Sep 29, 2015
  2. Use `:language` command to force C locale

    In non-Windows environments, the gpg command is prepended with “LANG=C
    LC_ALL=C” to ensure gpg's output is consistent to allow for parsing the
    information.  However, that doesn't work in Windows and won't
    necessarily work if we ever remove the code forcing use of /bin/sh.
    
    Since Vim already knows how to influence the environment, use its
    “:language message …” command to set/restore the locale before/after
    running the gpg command.
    
    Closes jamessan/vim-gnupg#45
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Sep 29, 2015
Commits on Jul 26, 2015
  1. Remove “--batch” from command used to detect encryption

    If the “log-file” option is set in ~/.gnupg/gpg.conf, then using “--batch”
    means that the CLI's “--logger-fd” is ignored.  Since this command
    shouldn't need any of “--batch”'s functionality and “log-file” hides all
    the output we're expecting, dropping “--batch” is the sane thing to do.
    
    Closes #40
    
    Signed-off-by: James McCoy <vega.james@gmail.com>
    
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    # On branch master
    # Your branch is up-to-date with 'origin/master'.
    #
    # Changes to be committed:
    #	modified:   plugin/gnupg.vim
    #
    # Untracked files:
    #	foo.asc
    #	foo.gpg
    #	foo.sig
    #
    # ------------------------ >8 ------------------------
    # Do not touch the line above.
    # Everything below will be removed.
    diff --git c/plugin/gnupg.vim i/plugin/gnupg.vim
    index 80f2061..b0bcd5c 100644
    --- c/plugin/gnupg.vim
    +++ i/plugin/gnupg.vim
    @@ -1,5 +1,5 @@
     " Name:    gnupg.vim
    -" Last Change: 2015 Jul 16
    +" Last Change: 2015 Jul 26
     " Maintainer:  James McCoy <vega.james@gmail.com>
     " Original Author:  Markus Braun <markus.braun@krawel.de>
     " Summary: Vim plugin for transparent editing of gpg encrypted files.
    @@ -448,7 +448,7 @@ function s:GPGDecrypt(bufread)
    
       " find the recipients of the file
       let cmd = { 'level': 3 }
    -  let cmd.args = '--verbose --decrypt --list-only --dry-run --batch --no-use-agent --logger-fd 1 ' . shellescape(filename)
    +  let cmd.args = '--verbose --decrypt --list-only --dry-run --no-use-agent --logger-fd 1 ' . shellescape(filename)
       let output = s:GPGSystem(cmd)
    
       " Suppress the "N more lines" message when editing a file, not when reading
    committed Jul 26, 2015
Commits on Jul 17, 2015
  1. Setup agent handling after determining gnupg's version

    Starting with release 2.1, gnupg will automatically run gpg-agent rather
    than requiring it to be run as a daemon.  The “--no-use-agent” switch
    was also marked deprecated, since it no longer does anything.
    
    This commit moves the --(no-)use-agent handling until after it is known
    what version of gpg is being used.
    
    Closes #37
    
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Jul 17, 2015
Commits on Mar 22, 2015
  1. Silence "No matching autocommands" for TermChanged event

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Mar 22, 2015
Commits on Mar 3, 2015
  1. Document that GPGSystem always uses temp files

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Mar 3, 2015
Commits on Feb 6, 2015
  1. Emit TermChanged when resetting &term

    Resetting &term can affect various settings which are terminal
    dependent (e.g., escape sequences described at “:help :set-termcap”).
    Emitting TermChanged allows people to re-set these options so they don't
    lose functionality (c.f. jamessan/vim-gnupg#28).
    
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Feb 6, 2015
Commits on Jan 6, 2015
  1. Trigger FileReadPost event after decrypting for :r

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Jan 6, 2015
  2. Manually set [ and ] marks after decrypting

    :lockmarks doesn't appear to preserve these marks.  They would need
    to be adjusted anyway due to the line numbers changing, so just set the
    marks to the start/end of the buffer.
    
    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Jan 6, 2015
  3. Emit BufReadPre/FileReadPre when decrypting the file

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Jan 6, 2015
Commits on Dec 25, 2014
  1. Don't change modified state of buffer for FileWriteCmd

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Dec 25, 2014
  2. Emit FileWritePre/Post events when handling FileWriteCmd

    Signed-off-by: James McCoy <vega.james@gmail.com>
    committed Dec 25, 2014