Permalink
Browse files

Update TMail to v1.1.0. Use an updated version of TMail if available.…

… [mikel]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8084 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 7464a39 commit 2a51c8682d44ee71a3c0411e2e30ef8ff29d6f67 @technoweenie technoweenie committed Nov 6, 2007
Showing with 1,610 additions and 338 deletions.
  1. +2 −0 actionmailer/CHANGELOG
  2. +10 −1 actionmailer/lib/action_mailer.rb
  3. +2 −1 actionmailer/lib/action_mailer/vendor/tmail.rb
  4. +19 −0 actionmailer/lib/action_mailer/vendor/tmail/Makefile
  5. +6 −3 actionmailer/lib/action_mailer/vendor/tmail/address.rb
  6. +6 −0 actionmailer/lib/action_mailer/vendor/tmail/attachments.rb
  7. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/base64.rb
  8. +39 −0 actionmailer/lib/action_mailer/vendor/tmail/compat.rb
  9. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/config.rb
  10. +67 −0 actionmailer/lib/action_mailer/vendor/tmail/core_extensions.rb
  11. +23 −9 actionmailer/lib/action_mailer/vendor/tmail/encode.rb
  12. +23 −6 actionmailer/lib/action_mailer/vendor/tmail/header.rb
  13. +540 −0 actionmailer/lib/action_mailer/vendor/tmail/interface.rb
  14. +20 −5 actionmailer/lib/action_mailer/vendor/tmail/mail.rb
  15. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/mailbox.rb
  16. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/net.rb
  17. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/obsolete.rb
  18. +234 −281 actionmailer/lib/action_mailer/vendor/tmail/parser.rb
  19. +381 −0 actionmailer/lib/action_mailer/vendor/tmail/parser.y
  20. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/port.rb
  21. +5 −0 actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
  22. +5 −3 actionmailer/lib/action_mailer/vendor/tmail/scanner.rb
  23. +6 −4 actionmailer/lib/action_mailer/vendor/tmail/stringio.rb
  24. +50 −7 actionmailer/lib/action_mailer/vendor/tmail/utils.rb
  25. +38 −0 actionmailer/lib/action_mailer/vendor/tmail/version.rb
  26. +104 −0 actionmailer/test/fixtures/raw_email_with_invalid_characters_in_content_type
@@ -1,5 +1,7 @@
*SVN*
+* Update TMail to v1.1.0. Use an updated version of TMail if available. [mikel]
+
* Introduce a new base test class for testing Mailers. ActionMailer::TestCase [Koz]
* Fix silent failure of rxml templates. #9879 [jstewart]
@@ -31,14 +31,23 @@
end
end
+# attempt to load the TMail gem
+begin
+ require 'rubygems'
+ gem 'TMail', '> 1.1.0'
+ require 'tmail'
+rescue Gem::LoadError
+ # no gem, fall back to vendor copy
+end
+
$:.unshift(File.dirname(__FILE__) + "/action_mailer/vendor/")
+require 'tmail'
require 'action_mailer/base'
require 'action_mailer/helpers'
require 'action_mailer/mail_helper'
require 'action_mailer/quoting'
require 'action_mailer/test_helper'
-require 'tmail'
require 'net/smtp'
ActionMailer::Base.class_eval do
@@ -1,3 +1,4 @@
-require 'tmail/info'
+require 'tmail/version'
require 'tmail/mail'
require 'tmail/mailbox'
+require 'tmail/core_extensions'
@@ -0,0 +1,19 @@
+#
+# lib/tmail/Makefile
+#
+
+debug:
+ rm -f parser.rb
+ make parser.rb DEBUG=true
+
+parser.rb: parser.y
+ if [ "$(DEBUG)" = true ]; then \
+ racc -v -g -o$@ parser.y ;\
+ else \
+ racc -E -o$@ parser.y ;\
+ fi
+
+clean:
+ rm -f parser.rb parser.output
+
+distclean: clean
@@ -1,5 +1,8 @@
-#
-# address.rb
+=begin rdoc
+
+= Address handling class
+
+=end
#
#--
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
@@ -51,6 +54,7 @@ def initialize( local, domain )
raise SyntaxError, 'empty word in domain' if s.empty?
end
end
+
@local = local
@domain = domain
@name = nil
@@ -96,7 +100,6 @@ def spec
alias address spec
-
def ==( other )
other.respond_to? :spec and self.spec == other.spec
end
@@ -1,3 +1,9 @@
+=begin rdoc
+
+= Attachment handling class
+
+=end
+
require 'stringio'
module TMail
@@ -1,6 +1,8 @@
-#
-# base64.rb
-#
+=begin rdoc
+
+= Base64 handling class
+
+=end
#--
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
#
@@ -0,0 +1,39 @@
+unless Enumerable.method_defined?(:map)
+ module Enumerable
+ alias map collect
+ end
+end
+
+unless Enumerable.method_defined?(:select)
+ module Enumerable
+ alias select find_all
+ end
+end
+
+unless Enumerable.method_defined?(:reject)
+ module Enumerable
+ def reject
+ result = []
+ each do |i|
+ result.push i unless yield(i)
+ end
+ result
+ end
+ end
+end
+
+unless Enumerable.method_defined?(:sort_by)
+ module Enumerable
+ def sort_by
+ map {|i| [yield(i), i] }.sort.map {|val, i| i }
+ end
+ end
+end
+
+unless File.respond_to?(:read)
+ def File.read(fname)
+ File.open(fname) {|f|
+ return f.read
+ }
+ end
+end
@@ -1,6 +1,8 @@
-#
-# config.rb
-#
+=begin rdoc
+
+= Configuration Class
+
+=end
#--
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
#
@@ -0,0 +1,67 @@
+=begin rdoc
+
+= Ruby on Rails Core Extensions
+
+provides .blank?
+
+=end
+unless Object.respond_to?(:blank?) #:nodoc:
+ # Check first to see if we are in a Rails environment, no need to
+ # define these methods if we are
+ class Object
+ # An object is blank if it's nil, empty, or a whitespace string.
+ # For example, "", " ", nil, [], and {} are blank.
+ #
+ # This simplifies
+ # if !address.nil? && !address.empty?
+ # to
+ # if !address.blank?
+ def blank?
+ if respond_to?(:empty?) && respond_to?(:strip)
+ empty? or strip.empty?
+ elsif respond_to?(:empty?)
+ empty?
+ else
+ !self
+ end
+ end
+ end
+
+ class NilClass #:nodoc:
+ def blank?
+ true
+ end
+ end
+
+ class FalseClass #:nodoc:
+ def blank?
+ true
+ end
+ end
+
+ class TrueClass #:nodoc:
+ def blank?
+ false
+ end
+ end
+
+ class Array #:nodoc:
+ alias_method :blank?, :empty?
+ end
+
+ class Hash #:nodoc:
+ alias_method :blank?, :empty?
+ end
+
+ class String #:nodoc:
+ def blank?
+ empty? || strip.empty?
+ end
+ end
+
+ class Numeric #:nodoc:
+ def blank?
+ false
+ end
+ end
+end
@@ -1,6 +1,8 @@
-#
-# encode.rb
-#
+=begin rdoc
+
+= Text Encoding class
+
+=end
#--
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
#
@@ -50,23 +52,25 @@ def create_dest( obj )
end
end
module_function :create_dest
-
+
def encoded( eol = "\r\n", charset = 'j', dest = nil )
accept_strategy Encoder, eol, charset, dest
end
-
+
def decoded( eol = "\n", charset = 'e', dest = nil )
+ # Turn the E-Mail into a string and return it with all
+ # encoded characters decoded. alias for to_s
accept_strategy Decoder, eol, charset, dest
end
-
+
alias to_s decoded
-
+
def accept_strategy( klass, eol, charset, dest = nil )
dest ||= ''
- accept klass.new(create_dest(dest), charset, eol)
+ accept klass.new( create_dest(dest), charset, eol )
dest
end
-
+
end
@@ -141,6 +145,7 @@ def phrase( str )
end
def kv_pair( k, v )
+ v = dquote(v) unless token_safe?(v)
@f << k << '=' << v
end
@@ -190,9 +195,18 @@ def initialize( dest = nil, encoding = nil, eol = "\r\n", limit = nil )
@f = StrategyInterface.create_dest(dest)
@opt = OPTIONS[$KCODE]
@eol = eol
+ @preserve_quotes = true
reset
end
+ def preserve_quotes=( bool )
+ @preserve_quotes
+ end
+
+ def preserve_quotes
+ @preserve_quotes
+ end
+
def normalize_encoding( str )
if @opt
then NKF.nkf(@opt, str)
@@ -1,5 +1,10 @@
-#
-# header.rb
+=begin rdoc
+
+= Header handling class
+
+=end
+# RFC #822 ftp://ftp.isi.edu/in-notes/rfc822.txt
+#
#
#--
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
@@ -76,6 +81,7 @@ def initialize( body, conf, intern = false )
@illegal = false
@parsed = false
+
if intern
@parsed = true
parse_init
@@ -129,7 +135,7 @@ def body=( str )
include StrategyInterface
- def accept( strategy, dummy1 = nil, dummy2 = nil )
+ def accept( strategy )
ensure_parsed
do_accept strategy
strategy.terminate
@@ -207,6 +213,7 @@ def parse_init
end
def do_parse
+ quote_boundary
obj = Parser.parse(self.class::PARSE_TYPE, @body, @comments)
set obj if obj
end
@@ -739,12 +746,17 @@ def content_type
def params
ensure_parsed
+ unless @params.blank?
+ @params.each do |k, v|
+ @params[k] = unquote(v)
+ end
+ end
@params
end
def []( key )
ensure_parsed
- @params and @params[key]
+ @params and unquote(@params[key])
end
def []=( key, val )
@@ -835,12 +847,17 @@ def disposition=( str )
def params
ensure_parsed
+ unless @params.blank?
+ @params.each do |k, v|
+ @params[k] = unquote(v)
+ end
+ end
@params
end
def []( key )
ensure_parsed
- @params and @params[key]
+ @params and unquote(@params[key])
end
def []=( key, val )
@@ -867,7 +884,7 @@ def do_accept( strategy )
@params.each do |k,v|
strategy.meta ';'
strategy.space
- strategy.kv_pair k, v
+ strategy.kv_pair k, unquote(v)
end
end
Oops, something went wrong. Retry.

0 comments on commit 2a51c86

Please sign in to comment.