Skip to content

Commit

Permalink
Closed #18814 - Fixed attchment.rb failing on mail part that had a ni…
Browse files Browse the repository at this point in the history
…l content-type (Mikel Lindsaar)
  • Loading branch information
mikel committed Mar 14, 2008
1 parent 526741f commit 2f5a796
Show file tree
Hide file tree
Showing 6 changed files with 1,138 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/tmail/attachments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def has_attachments?
end

def attachment?(part)
(part['content-disposition'] && part['content-disposition'].disposition == "attachment") ||
part.header['content-type'].main_type != "text"
part.disposition_is_attachment? || part.content_type_is_text?
end

def attachments
Expand Down
12 changes: 12 additions & 0 deletions lib/tmail/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,18 @@ def parts
def each_part( &block )
parts().each(&block)
end

# Returns true if the content type of this part of the email is
# a disposition attachment
def disposition_is_attachment?
(self['content-disposition'] && self['content-disposition'].disposition == "attachment")
end

# Returns true if this part's content main type is text, else returns false.
# By main type is meant "text/plain" is text. "text/html" is text
def content_type_is_text?
self.header['content-type'] && (self.header['content-type'].main_type != "text")
end

private

Expand Down
5 changes: 5 additions & 0 deletions log/BugTrackingLog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
== Fri Mar 14 12:01:31 GMT 2008 Mikel Lindsaar <raasdnil@gmail.com>

* Closed #18814 - Fixed attchment.rb failing on mail part that had a nil content-type (Mikel Lindsaar)

== Sat Mar 1 23:34:40 GMT 2008 Mikel Lindsaar <raasdnil@gmail.com>

* Closed #18516 - Fix TMail::Mail#preamble, and add #preamble= (Charles Lowe)

* Closed #18515 - Removed ftools from test case (Charles Lowe)

== Fri Feb 22 15:28:16 GMT 2008 Mikel Lindsaar <raasdnil@gmail.com>
Expand Down
Loading

0 comments on commit 2f5a796

Please sign in to comment.