[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] [PATCH] Implement inline GPG



Excerpts from Michael Stapelberg's message of Mo M�01 14:45:54 +0100 2010:
> Hi Rich,
> 
> Excerpts from Rich Lane's message of Sa Feb 27 19:05:58 +0100 2010:
> > The problem is sign_start will be nil if the text isn't on a line by
> > itself, causing a crash a few lines later. This happened to me when I
> How about using the following solution?
> 
> gpg_start = "-----BEGIN PGP SIGNED MESSAGE-----"
> gpg_end = "-----END PGP SIGNED MESSAGE-----"
> gpg = lines.select { |l| true if l =~ /#{gpg_start}/ .. l =~ /#{gpg_end}/ }
> msg.body = gpg.join("\n")
> 
> Is there a way to avoid the ugly "true if"? When just leaving it out, ruby
> complained saying "ArgumentError: bad value for range".

Hi, there,
tried this, but broke on this specific message, cause the string was
included but there was no signature.

This works for me:

517         ## Check for inline-PGP
518         if body =~ /^-----BEGIN PGP SIGNED MESSAGE-----/
519             gpg_start = "^-----BEGIN PGP SIGNED MESSAGE-----"
520             gpg_signature = "^-----BEGIN PGP SIGNATURE-----"
521             gpg_end = "^-----END PGP SIGNED MESSAGE-----"
522             gpg = lines.select { |l| true if l =~ /#{gpg_start}/ .. l =~ /#{gpg_end}/ }
523             body = lines.select { |l| true if l =~ /#{gpg_start}/ .. l =~ /#{gpg_signature}/ }
524             msg = RMail::Message.new
525             msg.body = gpg.join("\n")
526 
527             payload = RMail::Message.new
528             payload.body = body[1..-2].join("\n")
529 
530             File.open("/tmp/msg", "w+") {|f| f.write(msg.body)}
531             File.open("/tmp/payload", "w+") {|f| f.write(payload.body)}
532             return [CryptoManager.verify(nil, msg, false), message_to_chunks(payload)].flatten.compact
533         end

greetz didi
-- 
No documentation is better than bad documentation
-- Das Ausdrucken dieser Mail wird urheberrechtlich verfolgt.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel