提交 762295e0 编写于 作者: J Jeremy Kemper

Bundle tmail 1.2.3

上级 b4330932
......@@ -2,9 +2,9 @@
require 'rubygems'
begin
gem 'tmail', '~> 1.2.2'
gem 'tmail', '~> 1.2.3'
rescue Gem::LoadError
$:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.2"
$:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.3"
end
begin
......
......@@ -339,22 +339,36 @@ def encode_value( str )
def scanadd( str, force = false )
types = ''
strs = []
if str.respond_to?(:encoding)
enc = str.encoding
str.force_encoding(Encoding::ASCII_8BIT)
end
until str.empty?
if m = /\A[^\e\t\r\n ]+/.match(str)
types << (force ? 'j' : 'a')
strs.push m[0]
if str.respond_to?(:encoding)
strs.push m[0].force_encoding(enc)
else
strs.push m[0]
end
elsif m = /\A[\t\r\n ]+/.match(str)
types << 's'
strs.push m[0]
if str.respond_to?(:encoding)
strs.push m[0].force_encoding(enc)
else
strs.push m[0]
end
elsif m = /\A\e../.match(str)
esc = m[0]
str = m.post_match
if esc != "\e(B" and m = /\A[^\e]+/.match(str)
types << 'j'
strs.push m[0]
if str.respond_to?(:encoding)
strs.push m[0].force_encoding(enc)
else
strs.push m[0]
end
end
else
......@@ -453,7 +467,13 @@ def extract_J( chunksize, str )
size = max_bytes(chunksize, str.size) - 6
size = (size % 2 == 0) ? (size) : (size - 1)
return nil if size <= 0
"\e$B#{str.slice!(0, size)}\e(B"
if str.respond_to?(:encoding)
enc = str.encoding
str.force_encoding(Encoding::ASCII_8BIT)
"\e$B#{str.slice!(0, size)}\e(B".force_encoding(enc)
else
"\e$B#{str.slice!(0, size)}\e(B"
end
end
def extract_A( chunksize, str )
......
......@@ -591,12 +591,17 @@ def message_id( default = nil )
end
# Destructively sets the message ID of the mail object instance to the passed in string
#
# Invalid message IDs are ignored (silently, unless configured otherwise) and result in
# a nil message ID. Left and right angle brackets are required.
#
# Example:
#
# mail = TMail::Mail.new
# mail.message_id = "<348F04F142D69C21-291E56D292BC@xxxx.net>"
# mail.message_id #=> "<348F04F142D69C21-291E56D292BC@xxxx.net>"
# mail.message_id = "this_is_my_badly_formatted_message_id"
# mail.message_id #=> "this_is_my_badly_formatted_message_id"
# mail.message_id #=> nil
def message_id=( str )
set_string_attr 'Message-Id', str
end
......
......@@ -408,8 +408,8 @@ def parse_header( f )
when /\AFrom (\S+)/
unixfrom = $1
when /^charset=.*/
when /^charset=.*/
else
raise SyntaxError, "wrong mail header: '#{line.inspect}'"
end
......
......@@ -118,7 +118,7 @@ module TextUtils
ATOM_UNSAFE = /[#{Regexp.quote aspecial}#{control}#{lwsp}]/n
PHRASE_UNSAFE = /[#{Regexp.quote aspecial}#{control}]/n
TOKEN_UNSAFE = /[#{Regexp.quote tspecial}#{control}#{lwsp}]/n
# Returns true if the string supplied is free from characters not allowed as an ATOM
def atom_safe?( str )
not ATOM_UNSAFE === str
......
......@@ -32,7 +32,7 @@ module TMail
module VERSION
MAJOR = 1
MINOR = 2
TINY = 2
TINY = 3
STRING = [MAJOR, MINOR, TINY].join('.')
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册