Skip to content

Commit

Permalink
Mon Oct 24 17:50:00 2007 Mikel Lindsaar <raasdnil@gmail.com>
Browse files Browse the repository at this point in the history
	* Remaining failing tests are one encoding problem with
		relating to RFC 2231 and another problem where special
		characters are not properly quoted if they are the name
		portion of an email address (ie, TMail does not handle
		the address <"@"@example.com> properly)

	* Closed #14964 - The TMail from ActionMailer Preview Release
		2.0 is now fully merged into TMail branch 0.11.
		All previous tests and examples relating to TMail that
		were part of ActionMailer 2.0 Preview Release	now pass.

	* Closed #15008 - Fixed handling of multipart content type
		headers.  Now tested against many types of email.
		TMails' behaviour now is to take any boundary type, if
		it contains illegal characters, it will wrap it in ""
		when requesting the content type by mail['content-type]
		you will receive it unquoted, when outputting the email
		to_s as a whole you will receive the content-type field
		with the boundary section quoted if it contains illegal
		characters.

  * Replaced id with object_id line 221 in stringio.rb
  • Loading branch information
mikel committed Oct 24, 2007
1 parent a986977 commit c2e1a5a
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 245 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
@@ -1,3 +1,28 @@
Mon Oct 24 17:50:00 2007 Mikel Lindsaar <raasdnil@gmail.com>

* Remaining failing tests are one encoding problem with
relating to RFC 2231 and another problem where special
characters are not properly quoted if they are the name
portion of an email address (ie, TMail does not handle
the address <"@"@example.com> properly)

* Closed #14964 - The TMail from ActionMailer Preview Release
2.0 is now fully merged into TMail branch 0.11.
All previous tests and examples relating to TMail that
were part of ActionMailer 2.0 Preview Release now pass.

* Closed #15008 - Fixed handling of multipart content type
headers. Now tested against many types of email.
TMails' behaviour now is to take any boundary type, if
it contains illegal characters, it will wrap it in ""
when requesting the content type by mail['content-type]
you will receive it unquoted, when outputting the email
to_s as a whole you will receive the content-type field
with the boundary section quoted if it contains illegal
characters.

* Replaced id with object_id line 221 in stringio.rb

Mon Oct 24 15:35:00 2007 Mikel Lindsaar <raasdnil@gmail.com>

* Copied over the TMail/*.rb files from the TRUNK version of Rails
Expand Down
1 change: 0 additions & 1 deletion TODO
@@ -1,6 +1,5 @@
- RFC2231 decode
- delete File*Stream
- do not output empty/illegal header on to_s
- simplify field.rb
- allow raw JIS string in quoted word
- unify character encoding of japanese strings in header
Expand Down
28 changes: 8 additions & 20 deletions lib/tmail/header.rb
Expand Up @@ -215,22 +215,6 @@ def do_parse
set obj if obj
end

def quote_boundary
# Make sure the boundary is quoted (to ensure any special characters
# in the boundary text are escaped from the parser (such as = in MS
# Outlook's boundary text))
if @body =~ /^(.*?)boundary=(.*$)/
preamble = $1
boundary_text = $2
# Find out if it contains any of the RFC 2045 'specials' and needs
# to be quoted
if boundary_text =~ /[\/\?\=]/
boundary_text = "\"#{boundary_text}\"" unless boundary_text =~ /^".*?"$/
@body = "#{preamble}boundary=#{boundary_text}"
end
end
end

end


Expand Down Expand Up @@ -759,8 +743,10 @@ def content_type

def params
ensure_parsed
@params.each do |k, v|
@params[k] = unquote(v)
unless @params.blank?
@params.each do |k, v|
@params[k] = unquote(v)
end
end
@params
end
Expand Down Expand Up @@ -858,8 +844,10 @@ def disposition=( str )

def params
ensure_parsed
@params.each do |k, v|
@params[k] = unquote(v)
unless @params.blank?
@params.each do |k, v|
@params[k] = unquote(v)
end
end
@params
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tmail/info.rb
Expand Up @@ -29,7 +29,7 @@

module TMail

Version = '0.10.7'
Version = '0.11'
Copyright = 'Copyright (c) 1998-2002 Minero Aoki'

end
2 changes: 1 addition & 1 deletion lib/tmail/stringio.rb
Expand Up @@ -218,7 +218,7 @@ def size
alias pos size

def inspect
"#<#{self.class}:#{@dest ? 'open' : 'closed'},#{id}>"
"#<#{self.class}:#{@dest ? 'open' : 'closed'},#{object_id}>"
end

def print( *args )
Expand Down
197 changes: 0 additions & 197 deletions lib/tmail/textutils.rb

This file was deleted.

21 changes: 21 additions & 0 deletions lib/tmail/utils.rb
Expand Up @@ -240,6 +240,27 @@ def unquote( str )
end
end

def quote_boundary
# Make sure the boundary is quoted (to ensure any special characters
# in the boundary text are escaped from the parser (such as = in MS
# Outlook's boundary text))
if @body =~ /^(.*)boundary=(.*)$/m
preamble = $1
remainder = $2
if remainder =~ /;/
remainder =~ /^(.*)(;.*)$/m
boundary_text = $1
post = $2.chomp
else
boundary_text = remainder.chomp
end
if boundary_text =~ /[\/\?\=]/
boundary_text = "\"#{boundary_text}\"" unless boundary_text =~ /^".*?"$/
@body = "#{preamble}boundary=#{boundary_text}#{post}"
end
end
end

end

end
50 changes: 50 additions & 0 deletions test/fixtures/raw_email_with_multipart_mixed_quoted_boundary
@@ -0,0 +1,50 @@
From email_test@me.nowhere
Return-Path: <email_test@me.nowhere>
Received: from omta05sl.mx.bigpond.com by me.nowhere.else with ESMTP id 632BD5758 for <mikel@me.nowhere.else>; Sun, 21 Oct 2007 19:38:21 +1000
Received: from oaamta05sl.mx.bigpond.com by omta05sl.mx.bigpond.com with ESMTP id <20071021093820.HSPC16667.omta05sl.mx.bigpond.com@oaamta05sl.mx.bigpond.com> for <mikel@me.nowhere.else>; Sun, 21 Oct 2007 19:38:20 +1000
Received: from mikel091a by oaamta05sl.mx.bigpond.com with SMTP id <20071021093820.JFMT24025.oaamta05sl.mx.bigpond.com@mikel091a> for <mikel@me.nowhere.else>; Sun, 21 Oct 2007 19:38:20 +1000
Date: Sun, 21 Oct 2007 19:38:13 +1000
From: Mikel Lindsaar <email_test@me.nowhere>
Reply-To: Mikel Lindsaar <email_test@me.nowhere>
To: mikel@me.nowhere
Message-Id: <009601c813c6$19df3510$0437d30a@mikel091a>
Subject: Testing outlook
Subject: Another PDF
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_2192_32400445.1115745999735"
X-Virus-Scanned: amavisd-new at textdrive.com

------=_Part_2192_32400445.1115745999735
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Just attaching another PDF, here, to see what the message looks like,
and to see if I can figure out what is going wrong here.

------=_Part_2192_32400445.1115745999735
Content-Type: application/pdf; name="broken.pd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BUNLbguSO2YHujonAMJkMdSI7bIw91Akq2AUlMUWGFTMAOamjU
OvZQCxIkY2pCpMFo/IwLdVLHs6nddwTRrgoVbvLU9eB0G4EMndV0TNoxHbt3JBWwK6hhv3iHfDtF
yokB302IpEBTnWICde4uYc/1khDbSIkQopO6lcqamGBu1OSE3N5IPSsZX00CkSHRiiyx6HQIShsS
HSVNswdVsaOUSAWq9aYhDtGDaoG5a3lBGkYt/lFlBFt1UqrYnzVtUpUQnLiZeouKgf1KhRBViRRk
ExepJCzTwEmFDalIRbLEGtw0gfpESOpIAF/NnpPzcVCG86s0g2DuSyd41uhNGbEgaSrWEXORErbw
------=_Part_2192_32400445.1115745999735--

0 comments on commit c2e1a5a

Please sign in to comment.