actionmailer 3.0.0.beta2 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionmailer might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ *Rails 3.0.0 [beta 3] (April 13th, 2010)*
2
+
3
+ * Removed all quoting.rb type files from ActionMailer and put Mail 2.2.0 in instead [ML]
4
+
5
+ * Lot of updates to various test cases that now work better with the new Mail and so have different expectations
6
+
7
+
1
8
  *Rails 3.0.0 [beta 2] (April 1st, 2010)*
2
9
 
3
10
  * Added interceptors and observers from Mail [ML]
@@ -5,6 +12,16 @@
5
12
  ActionMailer::Base.register_interceptor calls Mail.register_interceptor
6
13
  ActionMailer::Base.register_observer calls Mail.register_observer
7
14
 
15
+ * Mail::Part now no longer has nil as a default charset, it is always set to something, and defaults to UTF-8
16
+
17
+ * Added explict setting of charset in set_fields! method to make sure Mail has the user defined default
18
+
19
+ * Removed quoting.rb and refactored for Mail to take responsibility of all quoting and auto encoding requirements for the header.
20
+
21
+ * Fixed several tests which had incorrect encoding.
22
+
23
+ * Changed all utf-8 to UTF-8 for consistency
24
+
8
25
  * Whole new API added with tests. See base.rb for full details. Old API is deprecated.
9
26
 
10
27
 
@@ -46,7 +46,6 @@ module ActionMailer
46
46
  autoload :DeprecatedApi
47
47
  autoload :MailHelper
48
48
  autoload :OldApi
49
- autoload :Quoting
50
49
  autoload :TestCase
51
50
  autoload :TestHelper
52
51
  end
@@ -207,7 +207,7 @@ module ActionMailer #:nodoc:
207
207
  # scores instead of hyphens, so <tt>Content-Transfer-Encoding:</tt>
208
208
  # becomes <tt>:content_transfer_encoding</tt>. The defaults set by Action Mailer are:
209
209
  # * <tt>:mime_version => "1.0"</tt>
210
- # * <tt>:charset => "utf-8",</tt>
210
+ # * <tt>:charset => "UTF-8",</tt>
211
211
  # * <tt>:content_type => "text/plain",</tt>
212
212
  # * <tt>:parts_order => [ "text/plain", "text/enriched", "text/html" ]</tt>
213
213
  #
@@ -264,7 +264,7 @@ module ActionMailer #:nodoc:
264
264
  # (i.e. multiple parts are assembled from templates which specify the content type in their
265
265
  # filenames) this variable controls how the parts are ordered.
266
266
  class Base < AbstractController::Base
267
- include DeliveryMethods, Quoting
267
+ include DeliveryMethods
268
268
  abstract!
269
269
 
270
270
  include AbstractController::Logger
@@ -286,7 +286,7 @@ module ActionMailer #:nodoc:
286
286
  class_attribute :default_params
287
287
  self.default_params = {
288
288
  :mime_version => "1.0",
289
- :charset => "utf-8",
289
+ :charset => "UTF-8",
290
290
  :content_type => "text/plain",
291
291
  :parts_order => [ "text/plain", "text/enriched", "text/html" ]
292
292
  }.freeze
@@ -375,6 +375,11 @@ module ActionMailer #:nodoc:
375
375
  process(method_name, *args) if method_name
376
376
  end
377
377
 
378
+ def process(*args) #:nodoc:
379
+ lookup_context.skip_default_locale!
380
+ super
381
+ end
382
+
378
383
  # Allows you to pass random and unusual headers to the new +Mail::Message+ object
379
384
  # which will add them to itself.
380
385
  #
@@ -525,19 +530,25 @@ module ActionMailer #:nodoc:
525
530
  content_type = headers[:content_type]
526
531
  parts_order = headers[:parts_order]
527
532
 
528
- # Merge defaults from class
533
+ # Handle defaults
529
534
  headers = headers.reverse_merge(self.class.default)
530
- charset = headers.delete(:charset)
531
-
532
- # Quote fields
533
535
  headers[:subject] ||= default_i18n_subject
534
- quote_fields!(headers, charset)
536
+
537
+ # Apply charset at the beginning so all fields are properly quoted
538
+ m.charset = charset = headers[:charset]
539
+
540
+ # Set configure delivery behavior
541
+ wrap_delivery_behavior!(headers.delete(:delivery_method))
542
+
543
+ # Assign all headers except parts_order, content_type and body
544
+ assignable = headers.except(:parts_order, :content_type, :body)
545
+ assignable.each { |k, v| m[k] = v }
535
546
 
536
547
  # Render the templates and blocks
537
548
  responses, explicit_order = collect_responses_and_parts_order(headers, &block)
538
- create_parts_from_responses(m, responses, charset)
549
+ create_parts_from_responses(m, responses)
539
550
 
540
- # Finally setup content type and parts order
551
+ # Setup content type, reapply charset and handle parts order
541
552
  m.content_type = set_content_type(m, content_type, headers[:content_type])
542
553
  m.charset = charset
543
554
 
@@ -547,12 +558,6 @@ module ActionMailer #:nodoc:
547
558
  m.body.sort_parts!
548
559
  end
549
560
 
550
- # Set configure delivery behavior
551
- wrap_delivery_behavior!(headers.delete(:delivery_method))
552
-
553
- # Remove any missing configuration header and assign all others
554
- headers.except!(:parts_order, :content_type)
555
- headers.each { |k, v| m[k] = v }
556
561
  m
557
562
  end
558
563
 
@@ -577,17 +582,6 @@ module ActionMailer #:nodoc:
577
582
  I18n.t(:subject, :scope => [:actionmailer, mailer_scope, action_name], :default => action_name.humanize)
578
583
  end
579
584
 
580
- # TODO: Move this into Mail
581
- def quote_fields!(headers, charset) #:nodoc:
582
- m = @_message
583
- m.subject ||= quote_if_necessary(headers.delete(:subject), charset) if headers[:subject]
584
- m.to ||= quote_address_if_necessary(headers.delete(:to), charset) if headers[:to]
585
- m.from ||= quote_address_if_necessary(headers.delete(:from), charset) if headers[:from]
586
- m.cc ||= quote_address_if_necessary(headers.delete(:cc), charset) if headers[:cc]
587
- m.bcc ||= quote_address_if_necessary(headers.delete(:bcc), charset) if headers[:bcc]
588
- m.reply_to ||= quote_address_if_necessary(headers.delete(:reply_to), charset) if headers[:reply_to]
589
- end
590
-
591
585
  def collect_responses_and_parts_order(headers) #:nodoc:
592
586
  responses, parts_order = [], nil
593
587
 
@@ -630,16 +624,16 @@ module ActionMailer #:nodoc:
630
624
  end
631
625
  end
632
626
 
633
- def create_parts_from_responses(m, responses, charset) #:nodoc:
627
+ def create_parts_from_responses(m, responses) #:nodoc:
634
628
  if responses.size == 1 && !m.has_attachments?
635
629
  responses[0].each { |k,v| m[k] = v }
636
630
  elsif responses.size > 1 && m.has_attachments?
637
631
  container = Mail::Part.new
638
632
  container.content_type = "multipart/alternative"
639
- responses.each { |r| insert_part(container, r, charset) }
633
+ responses.each { |r| insert_part(container, r, m.charset) }
640
634
  m.add_part(container)
641
635
  else
642
- responses.each { |r| insert_part(m, r, charset) }
636
+ responses.each { |r| insert_part(m, r, m.charset) }
643
637
  end
644
638
  end
645
639
 
@@ -143,12 +143,12 @@ module ActionMailer
143
143
  { :content_type => content_type,
144
144
  :content_disposition => content_disposition }.merge(params)
145
145
  end
146
-
146
+
147
147
  def create_mail
148
148
  m = @_message
149
149
 
150
- quote_fields!({:subject => subject, :to => recipients, :from => from,
151
- :bcc => bcc, :cc => cc, :reply_to => reply_to}, charset)
150
+ set_fields!({:subject => subject, :to => recipients, :from => from,
151
+ :bcc => bcc, :cc => cc, :reply_to => reply_to}, charset)
152
152
 
153
153
  m.mime_version = mime_version unless mime_version.nil?
154
154
  m.date = sent_on.to_time rescue sent_on if sent_on
@@ -230,6 +230,17 @@ module ActionMailer
230
230
  )
231
231
  end
232
232
 
233
+ def set_fields!(headers, charset) #:nodoc:
234
+ m = @_message
235
+ m.charset = charset
236
+ m.subject ||= headers.delete(:subject) if headers[:subject]
237
+ m.to ||= headers.delete(:to) if headers[:to]
238
+ m.from ||= headers.delete(:from) if headers[:from]
239
+ m.cc ||= headers.delete(:cc) if headers[:cc]
240
+ m.bcc ||= headers.delete(:bcc) if headers[:bcc]
241
+ m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to]
242
+ end
243
+
233
244
  def split_content_type(ct)
234
245
  ct.to_s.split("/")
235
246
  end
@@ -8,7 +8,7 @@ module ActionMailer
8
8
  end
9
9
 
10
10
  class TestCase < ActiveSupport::TestCase
11
- include Quoting, TestHelper
11
+ include TestHelper
12
12
 
13
13
  setup :initialize_test_deliveries
14
14
  setup :set_expected_mail
@@ -48,11 +48,11 @@ module ActionMailer
48
48
 
49
49
  private
50
50
  def charset
51
- "utf-8"
51
+ "UTF-8"
52
52
  end
53
53
 
54
54
  def encode(subject)
55
- quoted_printable(subject, charset)
55
+ Mail::Encodings.q_value_encode(subject, charset)
56
56
  end
57
57
 
58
58
  def read_fixture(action)
@@ -3,7 +3,7 @@ module ActionMailer
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "beta2"
6
+ BUILD = "beta3"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
9
9
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 3
7
7
  - 0
8
8
  - 0
9
- - beta2
10
- version: 3.0.0.beta2
9
+ - beta3
10
+ version: 3.0.0.beta3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Heinemeier Hansson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-01 00:00:00 -07:00
18
+ date: 2010-04-13 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -29,8 +29,8 @@ dependencies:
29
29
  - 3
30
30
  - 0
31
31
  - 0
32
- - beta2
33
- version: 3.0.0.beta2
32
+ - beta3
33
+ version: 3.0.0.beta3
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -42,10 +42,9 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  segments:
44
44
  - 2
45
- - 1
46
- - 5
47
- - 3
48
- version: 2.1.5.3
45
+ - 2
46
+ - 0
47
+ version: 2.2.0
49
48
  type: :runtime
50
49
  version_requirements: *id002
51
50
  - !ruby/object:Gem::Dependency
@@ -81,7 +80,6 @@ files:
81
80
  - lib/action_mailer/deprecated_api.rb
82
81
  - lib/action_mailer/mail_helper.rb
83
82
  - lib/action_mailer/old_api.rb
84
- - lib/action_mailer/quoting.rb
85
83
  - lib/action_mailer/railtie.rb
86
84
  - lib/action_mailer/railties/log_subscriber.rb
87
85
  - lib/action_mailer/test_case.rb
@@ -1,64 +0,0 @@
1
- module ActionMailer
2
- module Quoting #:nodoc:
3
- # TODO extract this into Mail itself.
4
- #
5
- #
6
- # Convert the given text into quoted printable format, with an instruction
7
- # that the text be eventually interpreted in the given charset.
8
- def quoted_printable(text, charset)
9
- text = text.gsub( /[^a-z ]/i ) { quoted_printable_encode($&) }.
10
- gsub( / /, "_" )
11
- "=?#{charset}?Q?#{text}?="
12
- end
13
-
14
- # Convert the given character to quoted printable format, taking into
15
- # account multi-byte characters (if executing with $KCODE="u", for instance)
16
- def quoted_printable_encode(character)
17
- result = ""
18
- character.each_byte { |b| result << "=%02X" % b }
19
- result
20
- end
21
-
22
- # A quick-and-dirty regexp for determining whether a string contains any
23
- # characters that need escaping.
24
- if !defined?(CHARS_NEEDING_QUOTING)
25
- CHARS_NEEDING_QUOTING = Regexp.new('[\000-\011\013\014\016-\037\177-\377]', nil, 'n')
26
- end
27
-
28
- # Quote the given text if it contains any "illegal" characters
29
- def quote_if_necessary(text, charset)
30
- text = text.dup.force_encoding(Encoding::ASCII_8BIT) if text.respond_to?(:force_encoding)
31
-
32
- (text =~ CHARS_NEEDING_QUOTING) ?
33
- quoted_printable(text, charset) :
34
- text
35
- end
36
-
37
- # Quote any of the given strings if they contain any "illegal" characters
38
- def quote_any_if_necessary(charset, *args)
39
- args.map { |v| quote_if_necessary(v, charset) }
40
- end
41
-
42
- # Quote the given address if it needs to be. The address may be a
43
- # regular email address, or it can be a phrase followed by an address in
44
- # brackets. The phrase is the only part that will be quoted, and only if
45
- # it needs to be. This allows extended characters to be used in the
46
- # "to", "from", "cc", "bcc" and "reply-to" headers.
47
- def quote_address_if_necessary(address, charset)
48
- if Array === address
49
- address.map { |a| quote_address_if_necessary(a, charset) }.join(", ")
50
- elsif address =~ /^(\S.*)\s+(<.*>)$/
51
- address = $2
52
- phrase = quote_if_necessary($1.gsub(/^['"](.*)['"]$/, '\1'), charset)
53
- "\"#{phrase}\" #{address}"
54
- else
55
- address
56
- end
57
- end
58
-
59
- # Quote any of the given addresses, if they need to be.
60
- def quote_any_address_if_necessary(charset, *args)
61
- args.map { |v| quote_address_if_necessary(v, charset) }
62
- end
63
- end
64
- end