lib/sup/message.rb in sup-0.22.1 vs lib/sup/message.rb in sup-0.23
- old
+ new
@@ -134,10 +134,15 @@
$1
elsif header["list-post"] =~ /@/
header["list-post"] # just try the whole fucking thing
end
address && Person.from_address(address)
+ elsif header["mailing-list"]
+ address = if header["mailing-list"] =~ /list (.*?);/
+ $1
+ end
+ address && Person.from_address(address)
elsif header["x-mailing-list"]
Person.from_address header["x-mailing-list"]
end
@recipient_email = header["envelope-to"] || header["x-original-to"] || header["delivered-to"]
@@ -262,18 +267,18 @@
## so i will keep this.
rmsg = location.parsed_message
parse_header rmsg.header
message_to_chunks rmsg
rescue SourceError, SocketError, RMail::EncodingUnsupportedError => e
- warn "problem reading message #{id}"
+ warn_with_location "problem reading message #{id}"
debug "could not load message: #{location.inspect}, exception: #{e.inspect}"
[Chunk::Text.new(error_message.split("\n"))]
rescue Exception => e
- warn "problem reading message #{id}"
+ warn_with_location "problem reading message #{id}"
debug "could not load message: #{location.inspect}, exception: #{e.inspect}"
raise e
end
@@ -402,23 +407,23 @@
## mime-encoded message, but need only see the delicious end
## product.
def multipart_signed_to_chunks m
if m.body.size != 2
- warn "multipart/signed with #{m.body.size} parts (expecting 2)"
+ warn_with_location "multipart/signed with #{m.body.size} parts (expecting 2)"
return
end
payload, signature = m.body
if signature.multipart?
- warn "multipart/signed with payload multipart #{payload.multipart?} and signature multipart #{signature.multipart?}"
+ warn_with_location "multipart/signed with payload multipart #{payload.multipart?} and signature multipart #{signature.multipart?}"
return
end
## this probably will never happen
if payload.header.content_type && payload.header.content_type.downcase == "application/pgp-signature"
- warn "multipart/signed with payload content type #{payload.header.content_type}"
+ warn_with_location "multipart/signed with payload content type #{payload.header.content_type}"
return
end
if signature.header.content_type && signature.header.content_type.downcase != "application/pgp-signature"
## unknown signature type; just ignore.
@@ -429,27 +434,27 @@
[CryptoManager.verify(payload, signature), message_to_chunks(payload)].flatten.compact
end
def multipart_encrypted_to_chunks m
if m.body.size != 2
- warn "multipart/encrypted with #{m.body.size} parts (expecting 2)"
+ warn_with_location "multipart/encrypted with #{m.body.size} parts (expecting 2)"
return
end
control, payload = m.body
if control.multipart?
- warn "multipart/encrypted with control multipart #{control.multipart?} and payload multipart #{payload.multipart?}"
+ warn_with_location "multipart/encrypted with control multipart #{control.multipart?} and payload multipart #{payload.multipart?}"
return
end
if payload.header.content_type && payload.header.content_type.downcase != "application/octet-stream"
- warn "multipart/encrypted with payload content type #{payload.header.content_type}"
+ warn_with_location "multipart/encrypted with payload content type #{payload.header.content_type}"
return
end
if control.header.content_type && control.header.content_type.downcase != "application/pgp-encrypted"
- warn "multipart/encrypted with control content type #{signature.header.content_type}"
+ warn_with_location "multipart/encrypted with control content type #{signature.header.content_type}"
return
end
notice, sig, decryptedm = CryptoManager.decrypt payload
if decryptedm # managed to decrypt
@@ -689,11 +694,11 @@
## like ":a:a:a:a:a" that occurred in certain emails.
if line =~ QUOTE_PATTERN || (line =~ /:$/ && line =~ /\w/ && nextline =~ QUOTE_PATTERN)
newstate = :quote
elsif line =~ SIG_PATTERN && (lines.length - i) < MAX_SIG_DISTANCE && !lines[(i+1)..-1].index { |l| l =~ /^-- $/ }
newstate = :sig
- elsif line =~ BLOCK_QUOTE_PATTERN
+ elsif line =~ BLOCK_QUOTE_PATTERN && nextline !~ QUOTE_PATTERN
newstate = :block_quote
end
if newstate
chunks << Chunk::Text.new(chunk_lines) unless chunk_lines.empty?
@@ -748,9 +753,14 @@
chunks << Chunk::Text.new(chunk_lines) unless chunk_lines.empty?
when :sig
chunks << Chunk::Signature.new(chunk_lines) unless chunk_lines.empty?
end
chunks
+ end
+
+ def warn_with_location msg
+ warn msg
+ warn "Message is in #{location.source.uri} at #{location.info}"
end
end
class Location
attr_reader :source