It looks like in 5918547, we're now using Encoding.default_internal if set. Rails sets Encoding.default_internal = Encoding::UTF_8 at startup time. This means that with gpgme 2.0.26, there's data corruption in the resulting file if encrypted from a Rails app.
Seeing as that commit was originally to fix #113, I'm now unsure if that was the correct fix given what can happen now if Encoding.default_internal is set to something that isn't binary.
repro
# setting Encoding.default_internal to utf-8 emulates what rails does
Encoding.default_internal = Encoding::UTF_8
require 'gpgme'
plaintext_path, recipient, outfile_path = ARGV
infile = File.open(plaintext_path, 'r')
outfile = File.open(outfile_path, 'wb')
GPGME::Crypto.new.encrypt(infile, recipients: recipient, output: outfile, always_trust: true)
outfile.close
ruby repro.rb plaintext.txt test@example.com test.gpg
❯ file *.gpg
output_2.0.24.gpg: PGP ECDH Public-Key Encrypted Session Key - keyid: AB4977DD 83722AD2
output_2.0.26.gpg: data
test.gpg: data
It looks like in 5918547, we're now using
Encoding.default_internalif set. Rails setsEncoding.default_internal = Encoding::UTF_8at startup time. This means that with gpgme 2.0.26, there's data corruption in the resulting file if encrypted from a Rails app.Seeing as that commit was originally to fix #113, I'm now unsure if that was the correct fix given what can happen now if
Encoding.default_internalis set to something that isn't binary.repro