gpg: fix error handling during decryption
An non-zero exit code from the execution of gpg during decryption would prevent aerc from parsing the output of gpg. The output should always be parsed. Gpg can exit with an error due to not being able to validate a signature. Aerc handles this error with the UI, and therefore all output should be parsed regardless of exit state of gpg. The parsing of stdout will find the errors and report back to aerc properly. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
parent
506f8f165c
commit
ccd76e6494
1 changed files with 5 additions and 3 deletions
|
@ -18,7 +18,11 @@ func Decrypt(r io.Reader) (*models.MessageDetails, error) {
|
||||||
}
|
}
|
||||||
args := []string{"--decrypt"}
|
args := []string{"--decrypt"}
|
||||||
g := newGpg(bytes.NewReader(orig), args)
|
g := newGpg(bytes.NewReader(orig), args)
|
||||||
err = g.cmd.Run()
|
_ = g.cmd.Run()
|
||||||
|
outRdr := bytes.NewReader(g.stdout.Bytes())
|
||||||
|
// Always parse stdout, even if there was an error running command.
|
||||||
|
// We'll find the error in the parsing
|
||||||
|
err = parse(outRdr, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = parseError(g.stderr.String())
|
err = parseError(g.stderr.String())
|
||||||
switch GPGErrors[err.Error()] {
|
switch GPGErrors[err.Error()] {
|
||||||
|
@ -29,7 +33,5 @@ func Decrypt(r io.Reader) (*models.MessageDetails, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outRdr := bytes.NewReader(g.stdout.Bytes())
|
|
||||||
parse(outRdr, md)
|
|
||||||
return md, nil
|
return md, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue