Project

General

Profile

« Previous | Next » 

Revision 037010aa

Added by Marc Dequènes over 14 years ago

  • ID 037010aaf3d826d773f8e271d010e18fb4b4fedb

[fix] ensure RFC3156 content is calculated with raw content when checking a signature (without TMail content reorganization) and using the TMail generated content when creating a new mail

View differences:

lib/tmail_gpg.rb
def verify_pgp_signature
return nil unless is_pgp_signed?
content = parts[0].to_rfc3156
content = parts[0].to_rfc3156(true)
sig = pgp_signature()
sigs_check = nil
......
{:signature => sig_data.read, :micalg => micalg}
end
def to_rfc3156
def to_rfc3156(untouched = false)
# - using RAW part, without any decoding
# - remove last EOL due to MIME protocol
# - remove lines containing only whitespaces
# - remove trailing whitespaces
# - properly convert all EOL to CRLF
raw.chomp.split(/\r?\n/, -1).select{|l| not l =~ /^ +$/}.join("\n").gsub(/ +$/, "").gsub(/\r?\n/, "\r\n")
txt = untouched ? self.raw : self.to_s
txt.chomp.split(/\r?\n/, -1).select{|l| not l =~ /^ +$/}.join("\n").gsub(/ +$/, "").gsub(/\r?\n/, "\r\n")
end
def create_encrypted(crypters_id)

Also available in: Unified diff