Skip to content
This repository
Browse code

Updated TMail to version 1.2.1 [raasdnil]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8620 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 2dda6391207fc7a7d36536306db36eed33f3af9d 1 parent a8eb90f
risk danger olson authored January 11, 2008

Showing 33 changed files with 1,319 additions and 671 deletions. Show diff stats Hide diff stats

  1. 4  actionmailer/CHANGELOG
  2. 4  actionmailer/lib/action_mailer/vendor.rb
  3. 540  actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/interface.rb
  4. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail.rb
  5. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/Makefile
  6. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/address.rb
  7. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/attachments.rb
  8. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/base64.rb
  9. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/compat.rb
  10. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/config.rb
  11. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/core_extensions.rb
  12. 126  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/encode.rb
  13. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/facade.rb
  14. 36  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/header.rb
  15. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/info.rb
  16. 1,123  actionmailer/lib/action_mailer/vendor/tmail-1.2.1/tmail/interface.rb
  17. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/loader.rb
  18. 47  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/mail.rb
  19. 6  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/mailbox.rb
  20. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/mbox.rb
  21. 35  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/net.rb
  22. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/obsolete.rb
  23. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/parser.rb
  24. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/parser.y
  25. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/port.rb
  26. 36  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/quoting.rb
  27. 14  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/scanner.rb
  28. 6  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/scanner_r.rb
  29. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/stringio.rb
  30. 0  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/tmail.rb
  31. 7  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/utils.rb
  32. 4  actionmailer/lib/action_mailer/vendor/{tmail-1.1.0 → tmail-1.2.1}/tmail/version.rb
  33. 2  actionmailer/test/mail_service_test.rb
4  actionmailer/CHANGELOG
@@ -2,6 +2,10 @@
2 2
 
3 3
 * Fixed that you don't have to call super in ActionMailer::TestCase#setup #10406 [jamesgolick]
4 4
 
  5
+* Updated TMail to version 1.2.1 [raasdnil]
  6
+
  7
+* Fixed test in mail_service_test.rb => 'test_decode_encoded_attachment_filename' which had an incorrect decode value (should have spaces in the file after decode) [raasdnil]
  8
+
5 9
 
6 10
 *2.0.2* (December 16th, 2007)
7 11
 
4  actionmailer/lib/action_mailer/vendor.rb
@@ -2,9 +2,9 @@
2 2
 require 'rubygems'
3 3
 
4 4
 begin
5  
-  gem 'tmail', '~> 1.1.0'
  5
+  gem 'tmail', '~> 1.2.1'
6 6
 rescue Gem::LoadError
7  
-  $:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.1.0"
  7
+  $:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.1"
8 8
 end
9 9
 
10 10
 begin
540  actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/interface.rb
... ...
@@ -1,540 +0,0 @@
1  
-=begin rdoc
2  
-
3  
-= Facade.rb Provides an interface to the TMail object
4  
-
5  
-=end
6  
-#--
7  
-# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
8  
-#
9  
-# Permission is hereby granted, free of charge, to any person obtaining
10  
-# a copy of this software and associated documentation files (the
11  
-# "Software"), to deal in the Software without restriction, including
12  
-# without limitation the rights to use, copy, modify, merge, publish,
13  
-# distribute, sublicense, and/or sell copies of the Software, and to
14  
-# permit persons to whom the Software is furnished to do so, subject to
15  
-# the following conditions:
16  
-#
17  
-# The above copyright notice and this permission notice shall be
18  
-# included in all copies or substantial portions of the Software.
19  
-#
20  
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  
-#
28  
-# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29  
-# with permission of Minero Aoki.
30  
-#++
31  
-
32  
-require 'tmail/utils'
33  
-
34  
-module TMail
35  
-
36  
-  class Mail
37  
-
38  
-    def header_string( name, default = nil )
39  
-      h = @header[name.downcase] or return default
40  
-      h.to_s
41  
-    end
42  
-
43  
-    ###
44  
-    ### attributes
45  
-    ###
46  
-
47  
-    include TextUtils
48  
-
49  
-    def set_string_array_attr( key, strs )
50  
-      strs.flatten!
51  
-      if strs.empty?
52  
-        @header.delete key.downcase
53  
-      else
54  
-        store key, strs.join(', ')
55  
-      end
56  
-      strs
57  
-    end
58  
-    private :set_string_array_attr
59  
-
60  
-    def set_string_attr( key, str )
61  
-      if str
62  
-        store key, str
63  
-      else
64  
-        @header.delete key.downcase
65  
-      end
66  
-      str
67  
-    end
68  
-    private :set_string_attr
69  
-
70  
-    def set_addrfield( name, arg )
71  
-      if arg
72  
-        h = HeaderField.internal_new(name, @config)
73  
-        h.addrs.replace [arg].flatten
74  
-        @header[name] = h
75  
-      else
76  
-        @header.delete name
77  
-      end
78  
-      arg
79  
-    end
80  
-    private :set_addrfield
81  
-
82  
-    def addrs2specs( addrs )
83  
-      return nil unless addrs
84  
-      list = addrs.map {|addr|
85  
-          if addr.address_group?
86  
-          then addr.map {|a| a.spec }
87  
-          else addr.spec
88  
-          end
89  
-      }.flatten
90  
-      return nil if list.empty?
91  
-      list
92  
-    end
93  
-    private :addrs2specs
94  
-
95  
-    #
96  
-    # date time
97  
-    #
98  
-
99  
-    def date( default = nil )
100  
-      if h = @header['date']
101  
-        h.date
102  
-      else
103  
-        default
104  
-      end
105  
-    end
106  
-
107  
-    def date=( time )
108  
-      if time
109  
-        store 'Date', time2str(time)
110  
-      else
111  
-        @header.delete 'date'
112  
-      end
113  
-      time
114  
-    end
115  
-
116  
-    def strftime( fmt, default = nil )
117  
-      if t = date
118  
-        t.strftime(fmt)
119  
-      else
120  
-        default
121  
-      end
122  
-    end
123  
-
124  
-    #
125  
-    # destination
126  
-    #
127  
-
128  
-    def to_addrs( default = nil )
129  
-      if h = @header['to']
130  
-        h.addrs
131  
-      else
132  
-        default
133  
-      end
134  
-    end
135  
-
136  
-    def cc_addrs( default = nil )
137  
-      if h = @header['cc']
138  
-        h.addrs
139  
-      else
140  
-        default
141  
-      end
142  
-    end
143  
-
144  
-    def bcc_addrs( default = nil )
145  
-      if h = @header['bcc']
146  
-        h.addrs
147  
-      else
148  
-        default
149  
-      end
150  
-    end
151  
-
152  
-    def to_addrs=( arg )
153  
-      set_addrfield 'to', arg
154  
-    end
155  
-
156  
-    def cc_addrs=( arg )
157  
-      set_addrfield 'cc', arg
158  
-    end
159  
-
160  
-    def bcc_addrs=( arg )
161  
-      set_addrfield 'bcc', arg
162  
-    end
163  
-
164  
-    def to( default = nil )
165  
-      addrs2specs(to_addrs(nil)) || default
166  
-    end
167  
-
168  
-    def cc( default = nil )
169  
-      addrs2specs(cc_addrs(nil)) || default
170  
-    end
171  
-
172  
-    def bcc( default = nil )
173  
-      addrs2specs(bcc_addrs(nil)) || default
174  
-    end
175  
-
176  
-    def to=( *strs )
177  
-      set_string_array_attr 'To', strs
178  
-    end
179  
-
180  
-    def cc=( *strs )
181  
-      set_string_array_attr 'Cc', strs
182  
-    end
183  
-
184  
-    def bcc=( *strs )
185  
-      set_string_array_attr 'Bcc', strs
186  
-    end
187  
-
188  
-    #
189  
-    # originator
190  
-    #
191  
-
192  
-    def from_addrs( default = nil )
193  
-      if h = @header['from']
194  
-        h.addrs
195  
-      else
196  
-        default
197  
-      end
198  
-    end
199  
-
200  
-    def from_addrs=( arg )
201  
-      set_addrfield 'from', arg
202  
-    end
203  
-
204  
-    def from( default = nil )
205  
-      addrs2specs(from_addrs(nil)) || default
206  
-    end
207  
-
208  
-    def from=( *strs )
209  
-      set_string_array_attr 'From', strs
210  
-    end
211  
-
212  
-    def friendly_from( default = nil )
213  
-      h = @header['from']
214  
-      a, = h.addrs
215  
-      return default unless a
216  
-      return a.phrase if a.phrase
217  
-      return h.comments.join(' ') unless h.comments.empty?
218  
-      a.spec
219  
-    end
220  
-
221  
-
222  
-    def reply_to_addrs( default = nil )
223  
-      if h = @header['reply-to']
224  
-        h.addrs
225  
-      else
226  
-        default
227  
-      end
228  
-    end
229  
-
230  
-    def reply_to_addrs=( arg )
231  
-      set_addrfield 'reply-to', arg
232  
-    end
233  
-
234  
-    def reply_to( default = nil )
235  
-      addrs2specs(reply_to_addrs(nil)) || default
236  
-    end
237  
-
238  
-    def reply_to=( *strs )
239  
-      set_string_array_attr 'Reply-To', strs
240  
-    end
241  
-
242  
-
243  
-    def sender_addr( default = nil )
244  
-      f = @header['sender'] or return default
245  
-      f.addr                or return default
246  
-    end
247  
-
248  
-    def sender_addr=( addr )
249  
-      if addr
250  
-        h = HeaderField.internal_new('sender', @config)
251  
-        h.addr = addr
252  
-        @header['sender'] = h
253  
-      else
254  
-        @header.delete 'sender'
255  
-      end
256  
-      addr
257  
-    end
258  
-
259  
-    def sender( default )
260  
-      f = @header['sender'] or return default
261  
-      a = f.addr            or return default
262  
-      a.spec
263  
-    end
264  
-
265  
-    def sender=( str )
266  
-      set_string_attr 'Sender', str
267  
-    end
268  
-
269  
-
270  
-    #
271  
-    # subject
272  
-    #
273  
-
274  
-    def subject( default = nil )
275  
-      if h = @header['subject']
276  
-        h.body
277  
-      else
278  
-        default
279  
-      end
280  
-    end
281  
-    alias quoted_subject subject
282  
-
283  
-    def subject=( str )
284  
-      set_string_attr 'Subject', str
285  
-    end
286  
-
287  
-    #
288  
-    # identity & threading
289  
-    #
290  
-
291  
-    def message_id( default = nil )
292  
-      if h = @header['message-id']
293  
-        h.id || default
294  
-      else
295  
-        default
296  
-      end
297  
-    end
298  
-
299  
-    def message_id=( str )
300  
-      set_string_attr 'Message-Id', str
301  
-    end
302  
-
303  
-    def in_reply_to( default = nil )
304  
-      if h = @header['in-reply-to']
305  
-        h.ids
306  
-      else
307  
-        default
308  
-      end
309  
-    end
310  
-
311  
-    def in_reply_to=( *idstrs )
312  
-      set_string_array_attr 'In-Reply-To', idstrs
313  
-    end
314  
-
315  
-    def references( default = nil )
316  
-      if h = @header['references']
317  
-        h.refs
318  
-      else
319  
-        default
320  
-      end
321  
-    end
322  
-
323  
-    def references=( *strs )
324  
-      set_string_array_attr 'References', strs
325  
-    end
326  
-
327  
-    #
328  
-    # MIME headers
329  
-    #
330  
-
331  
-    def mime_version( default = nil )
332  
-      if h = @header['mime-version']
333  
-        h.version || default
334  
-      else
335  
-        default
336  
-      end
337  
-    end
338  
-
339  
-    def mime_version=( m, opt = nil )
340  
-      if opt
341  
-        if h = @header['mime-version']
342  
-          h.major = m
343  
-          h.minor = opt
344  
-        else
345  
-          store 'Mime-Version', "#{m}.#{opt}"
346  
-        end
347  
-      else
348  
-        store 'Mime-Version', m
349  
-      end
350  
-      m
351  
-    end
352  
-
353  
-    def content_type( default = nil )
354  
-      if h = @header['content-type']
355  
-        h.content_type || default
356  
-      else
357  
-        default
358  
-      end
359  
-    end
360  
-
361  
-    def main_type( default = nil )
362  
-      if h = @header['content-type']
363  
-        h.main_type || default
364  
-      else
365  
-        default
366  
-      end
367  
-    end
368  
-
369  
-    def sub_type( default = nil )
370  
-      if h = @header['content-type']
371  
-        h.sub_type || default
372  
-      else
373  
-        default
374  
-      end
375  
-    end
376  
-
377  
-    def set_content_type( str, sub = nil, param = nil )
378  
-      if sub
379  
-        main, sub = str, sub
380  
-      else
381  
-        main, sub = str.split(%r</>, 2)
382  
-        raise ArgumentError, "sub type missing: #{str.inspect}" unless sub
383  
-      end
384  
-      if h = @header['content-type']
385  
-        h.main_type = main
386  
-        h.sub_type  = sub
387  
-        h.params.clear
388  
-      else
389  
-        store 'Content-Type', "#{main}/#{sub}"
390  
-      end
391  
-      @header['content-type'].params.replace param if param
392  
-      str
393  
-    end
394  
-
395  
-    alias content_type= set_content_type
396  
-    
397  
-    def type_param( name, default = nil )
398  
-      if h = @header['content-type']
399  
-        h[name] || default
400  
-      else
401  
-        default
402  
-      end
403  
-    end
404  
-
405  
-    def charset( default = nil )
406  
-      if h = @header['content-type']
407  
-        h['charset'] or default
408  
-      else
409  
-        default
410  
-      end
411  
-    end
412  
-
413  
-    def charset=( str )
414  
-      if str
415  
-        if h = @header[ 'content-type' ]
416  
-          h['charset'] = str
417  
-        else
418  
-          store 'Content-Type', "text/plain; charset=#{str}"
419  
-        end
420  
-      end
421  
-      str
422  
-    end
423  
-
424  
-    def transfer_encoding( default = nil )
425  
-      if h = @header['content-transfer-encoding']
426  
-        h.encoding || default
427  
-      else
428  
-        default
429  
-      end
430  
-    end
431  
-
432  
-    def transfer_encoding=( str )
433  
-      set_string_attr 'Content-Transfer-Encoding', str
434  
-    end
435  
-
436  
-    alias encoding                   transfer_encoding
437  
-    alias encoding=                  transfer_encoding=
438  
-    alias content_transfer_encoding  transfer_encoding
439  
-    alias content_transfer_encoding= transfer_encoding=
440  
-
441  
-    def disposition( default = nil )
442  
-      if h = @header['content-disposition']
443  
-        h.disposition || default
444  
-      else
445  
-        default
446  
-      end
447  
-    end
448  
-
449  
-    alias content_disposition     disposition
450  
-
451  
-    def set_disposition( str, params = nil )
452  
-      if h = @header['content-disposition']
453  
-        h.disposition = str
454  
-        h.params.clear
455  
-      else
456  
-        store('Content-Disposition', str)
457  
-        h = @header['content-disposition']
458  
-      end
459  
-      h.params.replace params if params
460  
-    end
461  
-
462  
-    alias disposition=            set_disposition
463  
-    alias set_content_disposition set_disposition
464  
-    alias content_disposition=    set_disposition
465  
-    
466  
-    def disposition_param( name, default = nil )
467  
-      if h = @header['content-disposition']
468  
-        h[name] || default
469  
-      else
470  
-        default
471  
-      end
472  
-    end
473  
-
474  
-    ###
475  
-    ### utils
476  
-    ###
477  
-
478  
-    def create_reply
479  
-      mail = TMail::Mail.parse('')
480  
-      mail.subject = 'Re: ' + subject('').sub(/\A(?:\[[^\]]+\])?(?:\s*Re:)*\s*/i, '')
481  
-      mail.to_addrs = reply_addresses([])
482  
-      mail.in_reply_to = [message_id(nil)].compact
483  
-      mail.references = references([]) + [message_id(nil)].compact
484  
-      mail.mime_version = '1.0'
485  
-      mail
486  
-    end
487  
-
488  
-    def base64_encode
489  
-      store 'Content-Transfer-Encoding', 'Base64'
490  
-      self.body = Base64.folding_encode(self.body)
491  
-    end
492  
-
493  
-    def base64_decode
494  
-      if /base64/i === self.transfer_encoding('')
495  
-        store 'Content-Transfer-Encoding', '8bit'
496  
-        self.body = Base64.decode(self.body, @config.strict_base64decode?)
497  
-      end
498  
-    end
499  
-
500  
-    def destinations( default = nil )
501  
-      ret = []
502  
-      %w( to cc bcc ).each do |nm|
503  
-        if h = @header[nm]
504  
-          h.addrs.each {|i| ret.push i.address }
505  
-        end
506  
-      end
507  
-      ret.empty? ? default : ret
508  
-    end
509  
-
510  
-    def each_destination( &block )
511  
-      destinations([]).each do |i|
512  
-        if Address === i
513  
-          yield i
514  
-        else
515  
-          i.each(&block)
516  
-        end
517  
-      end
518  
-    end
519  
-
520  
-    alias each_dest each_destination
521  
-
522  
-    def reply_addresses( default = nil )
523  
-      reply_to_addrs(nil) or from_addrs(nil) or default
524  
-    end
525  
-
526  
-    def error_reply_addresses( default = nil )
527  
-      if s = sender(nil)
528  
-        [s]
529  
-      else
530  
-        from_addrs(default)
531  
-      end
532  
-    end
533  
-
534  
-    def multipart?
535  
-      main_type('').downcase == 'multipart'
536  
-    end
537  
-
538  
-  end   # class Mail
539  
-
540  
-end   # module TMail
0  ...ler/lib/action_mailer/vendor/tmail-1.1.0/tmail.rb → ...ler/lib/action_mailer/vendor/tmail-1.2.1/tmail.rb
File renamed without changes
0  ...b/action_mailer/vendor/tmail-1.1.0/tmail/Makefile → ...b/action_mailer/vendor/tmail-1.2.1/tmail/Makefile
File renamed without changes
0  ...action_mailer/vendor/tmail-1.1.0/tmail/address.rb → ...action_mailer/vendor/tmail-1.2.1/tmail/address.rb
File renamed without changes
0  ...on_mailer/vendor/tmail-1.1.0/tmail/attachments.rb → ...on_mailer/vendor/tmail-1.2.1/tmail/attachments.rb
File renamed without changes
0  .../action_mailer/vendor/tmail-1.1.0/tmail/base64.rb → .../action_mailer/vendor/tmail-1.2.1/tmail/base64.rb
File renamed without changes
0  .../action_mailer/vendor/tmail-1.1.0/tmail/compat.rb → .../action_mailer/vendor/tmail-1.2.1/tmail/compat.rb
File renamed without changes
0  .../action_mailer/vendor/tmail-1.1.0/tmail/config.rb → .../action_mailer/vendor/tmail-1.2.1/tmail/config.rb
File renamed without changes
0  ...ailer/vendor/tmail-1.1.0/tmail/core_extensions.rb → ...ailer/vendor/tmail-1.2.1/tmail/core_extensions.rb
File renamed without changes
126  .../action_mailer/vendor/tmail-1.1.0/tmail/encode.rb → .../action_mailer/vendor/tmail-1.2.1/tmail/encode.rb
... ...
@@ -1,36 +1,35 @@
1  
-=begin rdoc
2  
-
3  
-= Text Encoding class
4  
-
5  
-=end
6  
-#--
7  
-# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
  1
+# = TITLE:
  2
+#
  3
+#   Text Encoding class
  4
+#
  5
+# = COPYRIGHT:
8 6
 #
9  
-# Permission is hereby granted, free of charge, to any person obtaining
10  
-# a copy of this software and associated documentation files (the
11  
-# "Software"), to deal in the Software without restriction, including
12  
-# without limitation the rights to use, copy, modify, merge, publish,
13  
-# distribute, sublicense, and/or sell copies of the Software, and to
14  
-# permit persons to whom the Software is furnished to do so, subject to
15  
-# the following conditions:
  7
+#   Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
16 8
 #
17  
-# The above copyright notice and this permission notice shall be
18  
-# included in all copies or substantial portions of the Software.
  9
+#   Permission is hereby granted, free of charge, to any person obtaining
  10
+#   a copy of this software and associated documentation files (the
  11
+#   "Software"), to deal in the Software without restriction, including
  12
+#   without limitation the rights to use, copy, modify, merge, publish,
  13
+#   distribute, sublicense, and/or sell copies of the Software, and to
  14
+#   permit persons to whom the Software is furnished to do so, subject to
  15
+#   the following conditions:
19 16
 #
20  
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17
+#   The above copyright notice and this permission notice shall be
  18
+#   included in all copies or substantial portions of the Software.
27 19
 #
28  
-# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29  
-# with permission of Minero Aoki.
30  
-#++
  20
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21
+#   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22
+#   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23
+#   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24
+#   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25
+#   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26
+#   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27
+#
  28
+#   Note: Originally licensed under LGPL v2+. Using MIT license for Rails
  29
+#   with permission of Minero Aoki.
31 30
 
32 31
 require 'nkf'
33  
-require 'tmail/base64.rb'
  32
+require 'tmail/base64'
34 33
 require 'tmail/stringio'
35 34
 require 'tmail/utils'
36 35
 
@@ -52,25 +51,25 @@ def create_dest( obj )
52 51
       end
53 52
     end
54 53
     module_function :create_dest
55  
-    
  54
+
56 55
     def encoded( eol = "\r\n", charset = 'j', dest = nil )
57 56
       accept_strategy Encoder, eol, charset, dest
58 57
     end
59  
-    
  58
+
60 59
     def decoded( eol = "\n", charset = 'e', dest = nil )
61 60
       # Turn the E-Mail into a string and return it with all
62 61
       # encoded characters decoded.  alias for to_s
63 62
       accept_strategy Decoder, eol, charset, dest
64 63
     end
65  
-    
  64
+
66 65
     alias to_s decoded
67  
-    
  66
+
68 67
     def accept_strategy( klass, eol, charset, dest = nil )
69 68
       dest ||= ''
70 69
       accept klass.new( create_dest(dest), charset, eol )
71 70
       dest
72 71
     end
73  
-    
  72
+
74 73
   end
75 74
 
76 75
 
@@ -121,7 +120,7 @@ def header_name( nm )
121 120
     def header_body( str )
122 121
       @f << decode(str)
123 122
     end
124  
-      
  123
+
125 124
     def space
126 125
       @f << ' '
127 126
     end
@@ -131,7 +130,7 @@ def space
131 130
     def lwsp( str )
132 131
       @f << str
133 132
     end
134  
-      
  133
+
135 134
     def meta( str )
136 135
       @f << str
137 136
     end
@@ -182,7 +181,8 @@ def Encoder.encode( str )
182 181
     end
183 182
 
184 183
     SPACER       = "\t"
185  
-    MAX_LINE_LEN = 70
  184
+    MAX_LINE_LEN = 78
  185
+    RFC_2822_MAX_LENGTH = 998
186 186
 
187 187
     OPTIONS = {
188 188
       'EUC'  => '-Ej -m0',
@@ -202,7 +202,7 @@ def initialize( dest = nil, encoding = nil, eol = "\r\n", limit = nil )
202 202
     def preserve_quotes=( bool )
203 203
       @preserve_quotes
204 204
     end
205  
-    
  205
+
206 206
     def preserve_quotes
207 207
       @preserve_quotes
208 208
     end
@@ -378,7 +378,7 @@ def concat_A_S( types, strs )
378 378
         i += 1
379 379
       end
380 380
     end
381  
-    
  381
+
382 382
     METHOD_ID = {
383 383
       ?j => :extract_J,
384 384
       ?e => :extract_E,
@@ -451,31 +451,73 @@ def add_lwsp( lwsp )
451 451
       # puts '---- lwsp -------------------------------------'
452 452
       # puts "+ #{lwsp.inspect}"
453 453
       fold if restsize() <= 0
454  
-      flush
  454
+      flush(@folded)
455 455
       @lwsp = lwsp
456 456
     end
457 457
 
458  
-    def flush
  458
+    def flush(folded = false)
459 459
       # puts '---- flush ----'
460 460
       # puts "spc >>>#{@lwsp.inspect}<<<"
461 461
       # puts "txt >>>#{@text.inspect}<<<"
462 462
       @f << @lwsp << @text
463  
-      @curlen += (@lwsp.size + @text.size)
  463
+      if folded
  464
+        @curlen = 0
  465
+      else
  466
+        @curlen += (@lwsp.size + @text.size)
  467
+      end
464 468
       @text = ''
465 469
       @lwsp = ''
466 470
     end
467 471
 
468 472
     def fold
469 473
       # puts '---- fold ----'
470  
-      @f << @eol
  474
+      unless @f.string =~ /^.*?:$/
  475
+        @f << @eol
  476
+        @lwsp = SPACER
  477
+      else
  478
+        fold_header
  479
+        @folded = true
  480
+      end
471 481
       @curlen = 0
472  
-      @lwsp = SPACER
  482
+    end
  483
+
  484
+    def fold_header
  485
+      # Called because line is too long - so we need to wrap.
  486
+      # First look for whitespace in the text
  487
+      # if it has text, fold there
  488
+      # check the remaining text, if too long, fold again
  489
+      # if it doesn't, then don't fold unless the line goes beyond 998 chars
  490
+
  491
+      # Check the text to see if there is whitespace, or if not
  492
+      @wrapped_text = []
  493
+      until @text == ''
  494
+        fold_the_string
  495
+      end
  496
+      @text = @wrapped_text.join("#{@eol}#{SPACER}")
  497
+    end
  498
+
  499
+    def fold_the_string
  500
+      whitespace_location = @text =~ /\s/ || @text.length
  501
+      # Is the location of the whitespace shorter than the RCF_2822_MAX_LENGTH?
  502
+      # if there is no whitespace in the string, then this
  503
+      unless mazsize(whitespace_location) <= 0
  504
+        @wrapped_text << @text.slice!(0...whitespace_location)
  505
+      # If it is not less, we have to wrap it destructively
  506
+      else
  507
+        slice_point = RFC_2822_MAX_LENGTH - @curlen - @lwsp.length
  508
+        @wrapped_text << @text.slice!(0...slice_point)
  509
+      end
473 510
     end
474 511
 
475 512
     def restsize
476 513
       MAX_LINE_LEN - (@curlen + @lwsp.size + @text.size)
477 514
     end
478 515
 
  516
+    def mazsize(whitespace_location)
  517
+      # Per RFC2822, the maximum length of a line is 998 chars
  518
+      RFC_2822_MAX_LENGTH - (@curlen + @lwsp.size + whitespace_location)
  519
+    end
  520
+
479 521
   end
480 522
 
481 523
 end    # module TMail
0  .../action_mailer/vendor/tmail-1.1.0/tmail/facade.rb → .../action_mailer/vendor/tmail-1.2.1/tmail/facade.rb
File renamed without changes
36  .../action_mailer/vendor/tmail-1.1.0/tmail/header.rb → .../action_mailer/vendor/tmail-1.2.1/tmail/header.rb
@@ -54,8 +54,40 @@ def new( name, body, conf = DEFAULT_CONFIG )
54 54
         klass.newobj body, conf
55 55
       end
56 56
 
  57
+      # Returns a HeaderField object matching the header you specify in the "name" param.
  58
+      # Requires an initialized TMail::Port to be passed in.
  59
+      #
  60
+      # The method searches the header of the Port you pass into it to find a match on
  61
+      # the header line you pass.  Once a match is found, it will unwrap the matching line
  62
+      # as needed to return an initialized HeaderField object.
  63
+      #
  64
+      # If you want to get the Envelope sender of the email object, pass in "EnvelopeSender",
  65
+      # if you want the From address of the email itself, pass in 'From'.
  66
+      #
  67
+      # This is because a mailbox doesn't have the : after the From that designates the
  68
+      # beginning of the envelope sender (which can be different to the from address of 
  69
+      # the emial)
  70
+      #
  71
+      # Other fields can be passed as normal, "Reply-To", "Received" etc.
  72
+      #
  73
+      # Note: Change of behaviour in 1.2.1 => returns nil if it does not find the specified
  74
+      # header field, otherwise returns an instantiated object of the correct header class
  75
+      # 
  76
+      # For example:
  77
+      #   port = TMail::FilePort.new("/test/fixtures/raw_email_simple")
  78
+      #   h = TMail::HeaderField.new_from_port(port, "From")
  79
+      #   h.addrs.to_s #=> "Mikel Lindsaar <mikel@nowhere.com>"
  80
+      #   h = TMail::HeaderField.new_from_port(port, "EvelopeSender")
  81
+      #   h.addrs.to_s #=> "mike@anotherplace.com.au"
  82
+      #   h = TMail::HeaderField.new_from_port(port, "SomeWeirdHeaderField")
  83
+      #   h #=> nil
57 84
       def new_from_port( port, name, conf = DEFAULT_CONFIG )
58  
-        re = Regep.new('\A(' + Regexp.quote(name) + '):', 'i')
  85
+        if name == "EnvelopeSender"
  86
+          name = "From"
  87
+          re = Regexp.new('\A(From) ', 'i')
  88
+        else
  89
+          re = Regexp.new('\A(' + Regexp.quote(name) + '):', 'i')
  90
+        end
59 91
         str = nil
60 92
         port.ropen {|f|
61 93
             f.each do |line|
@@ -66,7 +98,7 @@ def new_from_port( port, name, conf = DEFAULT_CONFIG )
66 98
               end
67 99
             end
68 100
         }
69  
-        new(name, str, Config.to_config(conf))
  101
+        new(name, str, Config.to_config(conf)) if str
70 102
       end
71 103
 
72 104
       def internal_new( name, conf )
0  ...ib/action_mailer/vendor/tmail-1.1.0/tmail/info.rb → ...ib/action_mailer/vendor/tmail-1.2.1/tmail/info.rb
File renamed without changes
1,123  actionmailer/lib/action_mailer/vendor/tmail-1.2.1/tmail/interface.rb
... ...
@@ -0,0 +1,1123 @@
  1
+=begin rdoc
  2
+
  3
+= interface.rb Provides an interface to the TMail object
  4
+
  5
+=end
  6
+#--
  7
+# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
  8
+#
  9
+# Permission is hereby granted, free of charge, to any person obtaining
  10
+# a copy of this software and associated documentation files (the
  11
+# "Software"), to deal in the Software without restriction, including
  12
+# without limitation the rights to use, copy, modify, merge, publish,
  13
+# distribute, sublicense, and/or sell copies of the Software, and to
  14
+# permit persons to whom the Software is furnished to do so, subject to
  15
+# the following conditions:
  16
+#
  17
+# The above copyright notice and this permission notice shall be
  18
+# included in all copies or substantial portions of the Software.
  19
+#
  20
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27
+#
  28
+# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
  29
+# with permission of Minero Aoki.
  30
+#++
  31
+
  32
+# TMail::Mail objects get accessed primarily through the methods in this file.
  33
+# 
  34
+# 
  35
+
  36
+require 'tmail/utils'
  37
+
  38
+module TMail
  39
+
  40
+  class Mail
  41
+
  42
+    # Allows you to query the mail object with a string to get the contents
  43
+    # of the field you want.
  44
+    # 
  45
+    # Returns a string of the exact contnts of the field
  46
+    # 
  47
+    #  mail.from = "mikel <mikel@lindsaar.net>"
  48
+    #  mail.header_string("From") #=> "mikel <mikel@lindsaar.net>"
  49
+    def header_string( name, default = nil )
  50
+      h = @header[name.downcase] or return default
  51
+      h.to_s
  52
+    end
  53
+
  54
+    #:stopdoc:
  55
+    #--
  56
+    #== Attributes
  57
+
  58
+    include TextUtils
  59
+
  60
+    def set_string_array_attr( key, strs )
  61
+      strs.flatten!
  62
+      if strs.empty?
  63
+        @header.delete key.downcase
  64
+      else
  65
+        store key, strs.join(', ')
  66
+      end
  67
+      strs
  68
+    end
  69
+    private :set_string_array_attr
  70
+
  71
+    def set_string_attr( key, str )
  72
+      if str
  73
+        store key, str
  74
+      else
  75
+        @header.delete key.downcase
  76
+      end
  77
+      str
  78
+    end
  79
+    private :set_string_attr
  80
+
  81
+    def set_addrfield( name, arg )
  82
+      if arg
  83
+        h = HeaderField.internal_new(name, @config)
  84
+        h.addrs.replace [arg].flatten
  85
+        @header[name] = h
  86
+      else
  87
+        @header.delete name
  88
+      end
  89
+      arg
  90
+    end
  91
+    private :set_addrfield
  92
+
  93
+    def addrs2specs( addrs )
  94
+      return nil unless addrs
  95
+      list = addrs.map {|addr|
  96
+          if addr.address_group?
  97
+          then addr.map {|a| a.spec }
  98
+          else addr.spec
  99
+          end
  100
+      }.flatten
  101
+      return nil if list.empty?
  102
+      list
  103
+    end
  104
+    private :addrs2specs
  105
+
  106
+    #:startdoc:
  107
+
  108
+    #== Date and Time methods
  109
+
  110
+    # Returns the date of the email message as per the "date" header value or returns
  111
+    # nil by default (if no date field exists).  
  112
+    # 
  113
+    # You can also pass whatever default you want into this method and it will return 
  114
+    # that instead of nil if there is no date already set. 
  115
+    def date( default = nil )
  116
+      if h = @header['date']
  117
+        h.date
  118
+      else
  119
+        default
  120
+      end
  121
+    end
  122
+
  123
+    # Destructively sets the date of the mail object with the passed Time instance,
  124
+    # returns a Time instance set to the date/time of the mail
  125
+    # 
  126
+    # Example:
  127
+    # 
  128
+    #  now = Time.now
  129
+    #  mail.date = now
  130
+    #  mail.date #=> Sat Nov 03 18:47:50 +1100 2007
  131
+    #  mail.date.class #=> Time
  132
+    def date=( time )
  133
+      if time
  134
+        store 'Date', time2str(time)
  135
+      else
  136
+        @header.delete 'date'
  137
+      end
  138
+      time
  139
+    end
  140
+
  141
+    # Returns the time of the mail message formatted to your taste using a 
  142
+    # strftime format string.  If no date set returns nil by default or whatever value
  143
+    # you pass as the second optional parameter.
  144
+    # 
  145
+    #  time = Time.now # (on Nov 16 2007)
  146
+    #  mail.date = time
  147
+    #  mail.strftime("%D") #=> "11/16/07"
  148
+    def strftime( fmt, default = nil )
  149
+      if t = date
  150
+        t.strftime(fmt)
  151
+      else
  152
+        default
  153
+      end
  154
+    end
  155
+
  156
+    #== Destination methods
  157
+
  158
+    # Return a TMail::Addresses instance for each entry in the "To:" field of the mail object header.
  159
+    # 
  160
+    # If the "To:" field does not exist, will return nil by default or the value you
  161
+    # pass as the optional parameter.
  162
+    # 
  163
+    # Example:
  164
+    #