tmail 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/CHANGES +50 -5
  2. data/MANIFEST +188 -0
  3. data/NOTES +1 -1
  4. data/README +10 -4
  5. data/Rakefile +1 -10
  6. data/lib/tmail.rb +1 -0
  7. data/lib/tmail/Makefile +0 -1
  8. data/lib/tmail/address.rb +190 -17
  9. data/lib/tmail/attachments.rb +1 -1
  10. data/lib/tmail/base64.rb +4 -10
  11. data/lib/tmail/compat.rb +8 -6
  12. data/lib/tmail/config.rb +2 -6
  13. data/lib/tmail/core_extensions.rb +14 -18
  14. data/lib/tmail/encode.rb +47 -12
  15. data/lib/tmail/header.rb +7 -10
  16. data/lib/tmail/index.rb +2 -1
  17. data/lib/tmail/interface.rb +14 -12
  18. data/lib/tmail/loader.rb +2 -0
  19. data/lib/tmail/mail.rb +83 -24
  20. data/lib/tmail/mailbox.rb +70 -10
  21. data/lib/tmail/main.rb +2 -0
  22. data/lib/tmail/mbox.rb +2 -0
  23. data/lib/tmail/net.rb +16 -15
  24. data/lib/tmail/obsolete.rb +7 -12
  25. data/lib/tmail/parser.rb +1 -0
  26. data/lib/tmail/require_arch.rb +2 -0
  27. data/lib/tmail/scanner.rb +2 -1
  28. data/lib/tmail/scanner_r.rb +11 -10
  29. data/lib/tmail/utils.rb +83 -26
  30. data/lib/tmail/version.rb +3 -2
  31. data/log/BugTrackingLog.txt +1208 -0
  32. data/log/{ChangeLog.txt → Changelog-0.txt} +36 -0
  33. data/log/Changelog.txt +534 -0
  34. data/log/Testlog.txt +114 -0
  35. data/log/Todo.txt +0 -2
  36. data/meta/VERSION +1 -0
  37. data/meta/project.yaml +8 -5
  38. data/meta/unixname +1 -0
  39. data/setup.rb +1481 -0
  40. data/site/contributing/index.html +183 -0
  41. data/site/css/clean.css +27 -0
  42. data/site/css/layout.css +31 -0
  43. data/site/css/style.css +60 -0
  44. data/site/download/index.html +61 -0
  45. data/site/img/envelope.jpg +0 -0
  46. data/site/img/mailman.gif +0 -0
  47. data/site/img/stamp-sm.jpg +0 -0
  48. data/site/img/stamp.jpg +0 -0
  49. data/site/img/stampborder.jpg +0 -0
  50. data/site/img/tfire.jpg +0 -0
  51. data/site/img/tmail.png +0 -0
  52. data/site/index.html +270 -0
  53. data/site/js/jquery.js +31 -0
  54. data/site/log/Changelog.xsl +33 -0
  55. data/site/log/changelog.xml +1677 -0
  56. data/site/outdated/BUGS +3 -0
  57. data/site/outdated/DEPENDS +1 -0
  58. data/site/outdated/Incompatibilities +89 -0
  59. data/site/outdated/Incompatibilities.ja +102 -0
  60. data/site/outdated/NEWS +9 -0
  61. data/site/outdated/README.ja +73 -0
  62. data/site/outdated/doc.ja/address.html +275 -0
  63. data/site/outdated/doc.ja/basics.html +405 -0
  64. data/site/outdated/doc.ja/config.html +49 -0
  65. data/site/outdated/doc.ja/details.html +146 -0
  66. data/site/outdated/doc.ja/index.html +39 -0
  67. data/site/outdated/doc.ja/mail.html +793 -0
  68. data/site/outdated/doc.ja/mailbox.html +265 -0
  69. data/site/outdated/doc.ja/port.html +95 -0
  70. data/site/outdated/doc.ja/tmail.html +58 -0
  71. data/site/outdated/doc.ja/usage.html +202 -0
  72. data/site/outdated/rdd/address.rrd.m +229 -0
  73. data/site/outdated/rdd/basics.rd.m +275 -0
  74. data/site/outdated/rdd/config.rrd.m +26 -0
  75. data/site/outdated/rdd/details.rd.m +117 -0
  76. data/site/outdated/rdd/index.rhtml.m +54 -0
  77. data/site/outdated/rdd/mail.rrd.m +701 -0
  78. data/site/outdated/rdd/mailbox.rrd.m +228 -0
  79. data/site/outdated/rdd/port.rrd.m +69 -0
  80. data/site/outdated/rdd/tmail.rrd.m +33 -0
  81. data/site/outdated/rdd/usage.rd.m +247 -0
  82. data/site/quickstart/index.html +69 -0
  83. data/site/quickstart/quickstart.html +52 -0
  84. data/site/quickstart/usage.html +193 -0
  85. data/site/reference/address.html +247 -0
  86. data/site/reference/config.html +30 -0
  87. data/site/reference/index.html +101 -0
  88. data/site/reference/mail.html +726 -0
  89. data/site/reference/mailbox.html +245 -0
  90. data/site/reference/port.html +75 -0
  91. data/site/reference/tmail.html +35 -0
  92. data/test/fixtures/mailbox +405 -4
  93. data/test/fixtures/raw_email_multiple_from +30 -0
  94. data/test/kcode.rb +2 -2
  95. data/test/temp_test_one.rb +46 -0
  96. data/test/test_address.rb +77 -38
  97. data/test/test_encode.rb +0 -2
  98. data/test/test_header.rb +47 -24
  99. data/test/test_mail.rb +52 -9
  100. data/test/test_mbox.rb +28 -0
  101. data/test/test_port.rb +33 -27
  102. data/test/test_quote.rb +35 -8
  103. data/work/script/make +26 -0
  104. data/work/script/rdoc +39 -0
  105. data/{script → work/script}/setup +0 -0
  106. data/work/script/test +30 -0
  107. metadata +249 -184
  108. data/log/History.txt +0 -40
  109. data/meta/config.yaml +0 -8
  110. data/meta/icli.yaml +0 -16
  111. data/meta/tmail.roll +0 -3
  112. data/script/changelog +0 -19
  113. data/script/clobber/distclean +0 -8
  114. data/script/clobber/package +0 -10
  115. data/script/compile +0 -32
  116. data/script/pack/gem +0 -93
  117. data/script/pack/tgz +0 -41
  118. data/script/pack/zip +0 -41
  119. data/script/prepare +0 -15
  120. data/script/publish +0 -51
  121. data/script/rdoc +0 -42
  122. data/script/release +0 -10
  123. data/script/stamp +0 -33
  124. data/script/stats +0 -138
  125. data/script/tag +0 -25
  126. data/script/test +0 -36
@@ -0,0 +1,30 @@
1
+ Delivered-To: tim@powerupdev.com
2
+ Return-Path: <www-data@mangaverde.net>
3
+ To: tim@powerupdev.com concierge@powerupdev.com
4
+ From: tim@powerupdev.com concierge@powerupdev.com
5
+ Subject: /home/svn/public/minebox revision 214
6
+ Reply-to: tim@powerupdev.com concierge@powerupdev.com
7
+ Message-Id: <20071022234523.5BD8E86D2@mangaverde.net>
8
+ Date: Mon, 22 Oct 2007 23:45:23 +0000 (UTC)
9
+
10
+ <p><b>recordkick</b> 2007-10-22 23:45:23 +0000 (Mon, 22 Oct 2007)</p><p>test
11
+ subversion<br>
12
+ </p><hr noshade><pre><font color=\"gray\">Modified:
13
+ trunk/README
14
+ ===================================================================
15
+ --- trunk/README\t2007-10-22
16
+ 23:41:34 UTC (rev 213)
17
+ +++ trunk/README\t2007-10-22 23:45:23 UTC (rev 214)
18
+ @@ -1,5 +1,5 @@
19
+ == Welcome
20
+ to Rails
21
+ -Test
22
+ +Tedst
23
+ Rails is a web-application and persistence framework that includes everything
24
+ needed
25
+ to create database-backed web-applications according to the
26
+ Model-View-Control pattern of separation. This pattern
27
+ splits the view (also
28
+
29
+ </font>
30
+ </pre>
@@ -3,10 +3,10 @@ module Test
3
3
  class TestCase
4
4
  def kcode(code)
5
5
  begin
6
- $KCODE = code
6
+ TMail.KCODE = code
7
7
  yield
8
8
  ensure
9
- $KCODE = 'NONE'
9
+ TMail.KCODE = 'NONE'
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,46 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+ require 'test_helper'
3
+ require 'tmail'
4
+ require 'kcode'
5
+ require 'time'
6
+
7
+ class TestMail < Test::Unit::TestCase
8
+ include TMail::TextUtils
9
+
10
+ def setup
11
+ @mail = TMail::Mail.new
12
+ end
13
+
14
+ def lf( str )
15
+ str.gsub(/\n|\r\n|\r/) { "\n" }
16
+ end
17
+
18
+ def crlf( str )
19
+ str.gsub(/\n|\r\n|\r/) { "\r\n" }
20
+ end
21
+
22
+ def test_MIME
23
+ # FIXME: test more.
24
+
25
+ kcode('EUC') {
26
+ mail = TMail::Mail.parse('From: hoge@example.jp (=?iso-2022-jp?B?GyRCJUYlOSVIGyhC?=)')
27
+ assert_not_nil mail['From']
28
+
29
+ expected = "\245\306\245\271\245\310"
30
+ if expected.respond_to? :force_encoding
31
+ expected.force_encoding(mail['From'].comments.first.encoding)
32
+ end
33
+ assert_equal [expected], mail['From'].comments
34
+
35
+ expected = "From: hoge@example.jp (\245\306\245\271\245\310)\n\n"
36
+ expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
37
+ assert_equal expected, mail.to_s
38
+ assert_equal expected, mail.decoded
39
+
40
+ expected = "From: hoge@example.jp (=?iso-2022-jp?B?GyRCJUYlOSVIGyhC?=)\r\n\r\n"
41
+ expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
42
+ assert_equal expected, mail.encoded
43
+ }
44
+ end
45
+
46
+ end
@@ -175,7 +175,7 @@ class TestAddress < Test::Unit::TestCase
175
175
  # "\e$BF|K\\8l\e(B"
176
176
  # GyRCRnxLXDhsGyhC
177
177
 
178
- $KCODE = 'NONE'
178
+ TMail.KCODE = 'NONE'
179
179
  validate_case__address\
180
180
  '=?iso-2022-jp?B?GyRCRnxLXDhsGyhC?= <aamine@loveruby.net>',
181
181
  :display_name => "\e$BF|K\\8l\e(B",
@@ -192,10 +192,12 @@ class TestAddress < Test::Unit::TestCase
192
192
  :domain => 'loveruby.net',
193
193
  :format => '=?iso-2022-jp?B?GyRCRnxLXDhsGyhC?= <aamine@loveruby.net>'
194
194
 
195
- $KCODE = 'EUC'
195
+ TMail.KCODE = 'EUC'
196
+ expected = "\306\374\313\334\270\354"
197
+ expected.force_encoding('EUC-JP') if expected.respond_to? :force_encoding
196
198
  validate_case__address\
197
199
  '=?iso-2022-jp?B?GyRCRnxLXDhsGyhC?= <aamine@loveruby.net>',
198
- :display_name => "\306\374\313\334\270\354",
200
+ :display_name => expected,
199
201
  :address => 'aamine@loveruby.net',
200
202
  :local => 'aamine',
201
203
  :domain => 'loveruby.net',
@@ -203,16 +205,18 @@ class TestAddress < Test::Unit::TestCase
203
205
 
204
206
  validate_case__address\
205
207
  '=?iso-2022-jp?Q?=1b=24=42=46=7c=4b=5c=38=6c=1b=28=42?= <aamine@loveruby.net>',
206
- :display_name => "\306\374\313\334\270\354",
208
+ :display_name => expected,
207
209
  :address => 'aamine@loveruby.net',
208
210
  :local => 'aamine',
209
211
  :domain => 'loveruby.net',
210
212
  :format => '=?iso-2022-jp?B?GyRCRnxLXDhsGyhC?= <aamine@loveruby.net>'
211
213
 
212
- $KCODE = 'SJIS'
214
+ TMail.KCODE = 'SJIS'
215
+ expected = "\223\372\226{\214\352"
216
+ expected.force_encoding('SJIS') if expected.respond_to? :force_encoding
213
217
  validate_case__address\
214
218
  '=?iso-2022-jp?B?GyRCRnxLXDhsGyhC?= <aamine@loveruby.net>',
215
- :display_name => "\223\372\226{\214\352",
219
+ :display_name => expected,
216
220
  :address => 'aamine@loveruby.net',
217
221
  :local => 'aamine',
218
222
  :domain => 'loveruby.net',
@@ -220,7 +224,7 @@ class TestAddress < Test::Unit::TestCase
220
224
 
221
225
  validate_case__address\
222
226
  '=?iso-2022-jp?Q?=1b=24=42=46=7c=4b=5c=38=6c=1b=28=42?= <aamine@loveruby.net>',
223
- :display_name => "\223\372\226{\214\352",
227
+ :display_name => expected,
224
228
  :address => 'aamine@loveruby.net',
225
229
  :local => 'aamine',
226
230
  :domain => 'loveruby.net',
@@ -229,11 +233,11 @@ class TestAddress < Test::Unit::TestCase
229
233
 
230
234
  def test_parse__rawjp
231
235
  begin
232
- $KCODE = 'EUC'
236
+ TMail.KCODE = 'EUC'
233
237
  _test_parse__euc
234
238
  _test_parse__jis
235
239
  ensure
236
- $KCODE = 'NONE'
240
+ TMail.KCODE = 'NONE'
237
241
  end
238
242
  end
239
243
 
@@ -253,7 +257,7 @@ class TestAddress < Test::Unit::TestCase
253
257
  # raw iso-2022-jp string in comment
254
258
  validate_case__address\
255
259
  "Minero Aoki (\e$B@DLZJvO:\e(B) <aamine@loveruby.net>",
256
- :display_name => 'Minero Aoki',
260
+ :display_name => "Minero Aoki (\e$B@DLZJvO:\e(B)",
257
261
  :address => 'aamine@loveruby.net',
258
262
  :local => 'aamine',
259
263
  :domain => 'loveruby.net',
@@ -691,7 +695,7 @@ class TestAddress < Test::Unit::TestCase
691
695
  validate_case__address\
692
696
  '(foo@bar.com (foobar), ned@foo.com (nedfoo) ) <kevin@goess.org>',
693
697
  :name => 'foo@bar.com (foobar), ned@foo.com (nedfoo) ',
694
- :display_name => nil,
698
+ :display_name => "(foo@bar.com (foobar), ned@foo.com (nedfoo) )",
695
699
  :address => 'kevin@goess.org',
696
700
  :comments => ['foo@bar.com (foobar), ned@foo.com (nedfoo) '],
697
701
  :domain => 'goess.org',
@@ -886,32 +890,6 @@ class TestAddress < Test::Unit::TestCase
886
890
  :local => 'bob',
887
891
  :format => 'bob'
888
892
 
889
- =begin
890
- validate_case__address\
891
- ['bob,sally, sam',
892
- [ { :name => nil,
893
- :display_name => nil,
894
- :address => 'bob',
895
- :comments => nil,
896
- :domain => nil,
897
- :local => 'bob',
898
- :format => 'bob' },
899
- { :name => nil,
900
- :display_name => nil,
901
- :address => 'sally',
902
- :comments => nil,
903
- :domain => nil,
904
- :local => 'sally',
905
- :format => 'sally' },
906
- { :name => nil,
907
- :display_name => nil,
908
- :address => 'sam',
909
- :comments => nil,
910
- :domain => nil,
911
- :local => 'sam',
912
- :format => 'sam' }] ]
913
- =end
914
-
915
893
  assert_raises(TMail::SyntaxError) {
916
894
  TMail::Address.parse 'Undisclosed <>'
917
895
  }
@@ -1138,7 +1116,7 @@ class TestAddress < Test::Unit::TestCase
1138
1116
 
1139
1117
  end
1140
1118
 
1141
- def test_full_stop_in_local()
1119
+ def test_full_stop_as_last_char_in_display_name()
1142
1120
 
1143
1121
  validate_case__address\
1144
1122
  %Q(Minero A. <aamine@loveruby.net>),
@@ -1152,5 +1130,66 @@ class TestAddress < Test::Unit::TestCase
1152
1130
 
1153
1131
  end
1154
1132
 
1133
+ def test_unquoted_at_char_in_name()
1134
+
1135
+ validate_case__address\
1136
+ %Q(mikel@me.com <lindsaar@you.net>),
1137
+ :name => "mikel@me.com",
1138
+ :display_name => "mikel@me.com",
1139
+ :address => %Q(lindsaar@you.net),
1140
+ :comments => nil,
1141
+ :domain => 'you.net',
1142
+ :local => %Q(lindsaar),
1143
+ :format => %Q("mikel@me.com" <lindsaar@you.net>)
1155
1144
 
1145
+ end
1146
+
1147
+ def test_special_quote_quoting_at_char_in_string
1148
+ string = 'mikel@me.com <mikel@me.com>'
1149
+ result = '"mikel@me.com" <mikel@me.com>'
1150
+ assert_equal(result, TMail::Address.special_quote_address(string))
1151
+ end
1152
+
1153
+ def test_special_quote_not_quoting_already_quoted_at_char_in_string
1154
+ string = '"mikel@me.com" <mikel@me.com>'
1155
+ result = '"mikel@me.com" <mikel@me.com>'
1156
+ assert_equal(result, TMail::Address.special_quote_address(string))
1157
+ end
1158
+
1159
+ def test_special_quote_not_quoting_something_without_an_at_char_and_quoted
1160
+ string = '"mikel" <mikel@me.com>'
1161
+ result = '"mikel" <mikel@me.com>'
1162
+ assert_equal(result, TMail::Address.special_quote_address(string))
1163
+ end
1164
+
1165
+ def test_special_quote_not_quoting_something_without_an_at_char_in_header
1166
+ string = 'mikel <mikel@me.com>'
1167
+ result = 'mikel <mikel@me.com>'
1168
+ assert_equal(result, TMail::Address.special_quote_address(string))
1169
+ end
1170
+
1171
+ def test_special_quoting_a_trailing_dot
1172
+ string = 'mikel. <mikel@me.com>'
1173
+ result = '"mikel." <mikel@me.com>'
1174
+ assert_equal(result, TMail::Address.special_quote_address(string))
1175
+ end
1176
+
1177
+ def test_special_quoting_a_trailing_dot_by_itself
1178
+ string = 'mikel . <mikel@me.com>'
1179
+ result = '"mikel ." <mikel@me.com>'
1180
+ assert_equal(result, TMail::Address.special_quote_address(string))
1181
+ end
1182
+
1183
+ def test_special_quoting_a_trailing_dot_by_itself_already_quoted
1184
+ string = '"mikel ." <mikel@me.com>'
1185
+ result = '"mikel ." <mikel@me.com>'
1186
+ assert_equal(result, TMail::Address.special_quote_address(string))
1187
+ end
1188
+
1189
+ def test_special_quoting_a_trailing_dot_by_itself_quoted
1190
+ string = 'mikel "." <mikel@me.com>'
1191
+ result = 'mikel "." <mikel@me.com>'
1192
+ assert_equal(result, TMail::Address.special_quote_address(string))
1193
+ end
1194
+
1156
1195
  end
@@ -3,8 +3,6 @@ require 'tmail/port'
3
3
  require 'tmail/encode'
4
4
  require 'nkf'
5
5
  require 'test/unit'
6
- require 'rubygems'
7
- require 'ruby-debug'
8
6
 
9
7
  class TestEncode < Test::Unit::TestCase
10
8
 
@@ -95,7 +95,12 @@ class AddressHeaderTester < Test::Unit::TestCase
95
95
  assert_equal ok[:routes], a.routes, str.inspect + " (routes)\n"
96
96
  assert_equal ok[:spec], a.spec, str.inspect + " (spec)\n"
97
97
  end
98
+ if comments.first.respond_to? :force_encoding
99
+ encoding = h.comments.first.encoding
100
+ comments.each { |c| c.force_encoding encoding }
101
+ end
98
102
  assert_equal comments, h.comments, str.inspect + " (comments)\n"
103
+ to_s.force_encoding(h.to_s.encoding) if to_s.respond_to? :force_encoding
99
104
  assert_equal to_s, h.to_s, str.inspect + " (to_s)\n" if to_s
100
105
  assert_equal to_s, h.decoded, str.inspect + " (decoded)\n" if to_s
101
106
  end
@@ -753,12 +758,12 @@ class ContentDispositionHeaderTester < Test::Unit::TestCase
753
758
  _test_raw_sjis
754
759
  _test_code_conversion
755
760
  ensure
756
- $KCODE = 'NONE'
761
+ TMail.KCODE = 'NONE'
757
762
  end
758
763
  end
759
764
 
760
765
  def _test_ATTRS
761
- $KCODE = 'NONE'
766
+ TMail.KCODE = 'NONE'
762
767
 
763
768
  h = TMail::HeaderField.new('Content-Disposition',
764
769
  'attachment; filename="README.txt.pif"')
@@ -787,17 +792,19 @@ class ContentDispositionHeaderTester < Test::Unit::TestCase
787
792
  end
788
793
 
789
794
  def _test_rfc2231_decode
790
- $KCODE = 'EUC'
795
+ TMail.KCODE = 'EUC'
791
796
 
792
797
  h = TMail::HeaderField.new('Content-Disposition',
793
798
  "attachment; filename*=iso-2022-jp'ja'%1b$B$Q$i$`%1b%28B")
794
799
  assert_equal 'attachment', h.disposition
795
800
  assert_equal 1, h.params.size
796
- assert_equal "\244\321\244\351\244\340", h.params['filename']
801
+ expected = "\244\321\244\351\244\340"
802
+ expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
803
+ assert_equal expected, h.params['filename']
797
804
  end
798
805
 
799
806
  def _test_rfc2231_encode
800
- $KCODE = 'EUC'
807
+ TMail.KCODE = 'EUC'
801
808
 
802
809
  h = TMail::HeaderField.new('Content-Disposition', 'a; n=a')
803
810
  h['n'] = "\245\265\245\363\245\327\245\353.txt"
@@ -811,73 +818,85 @@ class ContentDispositionHeaderTester < Test::Unit::TestCase
811
818
  end
812
819
 
813
820
  def _test_raw_iso2022jp
814
- $KCODE = 'EUC'
821
+ TMail.KCODE = 'EUC'
815
822
  # raw iso2022jp string in value (token)
816
823
  h = TMail::HeaderField.new('Content-Disposition',
817
824
  %Q<attachment; filename=\e$BF|K\\8l\e(B.doc>)
818
825
  assert_equal 'attachment', h.disposition
819
826
  assert_equal 1, h.params.size
820
827
  # assert_equal "\e$BF|K\\8l\e(B.doc", h.params['filename']
821
- assert_equal "\306\374\313\334\270\354.doc", h.params['filename']
822
828
 
829
+ expected = "\306\374\313\334\270\354.doc"
830
+ expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
831
+
832
+ assert_equal expected, h.params['filename']
833
+
823
834
  # raw iso2022jp string in value (quoted string)
824
835
  h = TMail::HeaderField.new('Content-Disposition',
825
836
  %Q<attachment; filename="\e$BF|K\\8l\e(B.doc">)
826
837
  assert_equal 'attachment', h.disposition
827
838
  assert_equal 1, h.params.size
828
839
  # assert_equal "\e$BF|K\\8l\e(B.doc", h.params['filename']
829
- assert_equal "\306\374\313\334\270\354.doc", h.params['filename']
840
+ assert_equal expected, h.params['filename']
830
841
  end
831
842
 
832
843
  def _test_raw_eucjp
833
- $KCODE = 'EUC'
844
+ TMail.KCODE = 'EUC'
834
845
  # raw EUC-JP string in value (token)
835
846
  h = TMail::HeaderField.new('Content-Disposition',
836
847
  %Q<attachment; filename=\306\374\313\334\270\354.doc>)
837
848
  assert_equal 'attachment', h.disposition
838
849
  assert_equal 1, h.params.size
839
- assert_equal "\306\374\313\334\270\354.doc", h.params['filename']
850
+ expected = "\306\374\313\334\270\354.doc"
851
+ expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
852
+ assert_equal expected, h.params['filename']
840
853
 
841
854
  # raw EUC-JP string in value (quoted-string)
842
855
  h = TMail::HeaderField.new('Content-Disposition',
843
856
  %Q<attachment; filename="\306\374\313\334\270\354.doc">)
844
857
  assert_equal 'attachment', h.disposition
845
858
  assert_equal 1, h.params.size
846
- assert_equal "\306\374\313\334\270\354.doc", h.params['filename']
859
+ assert_equal expected, h.params['filename']
847
860
  end
848
861
 
849
862
  def _test_raw_sjis
850
- $KCODE = 'SJIS'
863
+ TMail.KCODE = 'SJIS'
851
864
  # raw SJIS string in value (token)
852
865
  h = TMail::HeaderField.new('Content-Disposition',
853
866
  %Q<attachment; filename=\223\372\226{\214\352.doc>)
854
867
  assert_equal 'attachment', h.disposition
855
868
  assert_equal 1, h.params.size
856
- assert_equal "\223\372\226{\214\352.doc", h.params['filename']
869
+ expected = "\223\372\226{\214\352.doc"
870
+ expected.force_encoding 'Shift_JIS' if expected.respond_to? :force_encoding
871
+ assert_equal expected, h.params['filename']
857
872
 
858
873
  # raw SJIS string in value (quoted-string)
859
874
  h = TMail::HeaderField.new('Content-Disposition',
860
875
  %Q<attachment; filename="\223\372\226{\214\352.doc">)
861
876
  assert_equal 'attachment', h.disposition
862
877
  assert_equal 1, h.params.size
863
- assert_equal "\223\372\226{\214\352.doc", h.params['filename']
878
+ assert_equal expected, h.params['filename']
864
879
  end
865
880
 
866
881
  def _test_code_conversion
867
- # JIS -> $KCODE auto conversion
868
- $KCODE = 'EUC'
882
+ # JIS -> TMail.KCODE auto conversion
883
+ TMail.KCODE = 'EUC'
869
884
  h = TMail::HeaderField.new('Content-Disposition',
870
885
  %Q<attachment; filename=\e$BF|K\\8l\e(B.doc>)
871
886
  assert_equal 'attachment', h.disposition
872
887
  assert_equal 1, h.params.size
873
- assert_equal "\306\374\313\334\270\354.doc", h.params['filename']
888
+ expected = "\306\374\313\334\270\354.doc"
889
+ expected.force_encoding 'EUC-JP' if expected.respond_to? :force_encoding
890
+ assert_equal expected, h.params['filename']
874
891
 
875
- $KCODE = 'SJIS'
892
+ TMail.KCODE = 'SJIS'
876
893
  h = TMail::HeaderField.new('Content-Disposition',
877
894
  %Q<attachment; filename=\e$BF|K\\8l\e(B.doc>)
878
895
  assert_equal 'attachment', h.disposition
879
896
  assert_equal 1, h.params.size
880
- assert_equal "\223\372\226{\214\352.doc", h.params['filename']
897
+ expected = "\223\372\226{\214\352.doc"
898
+ expected.force_encoding 'Shift_JIS' if expected.respond_to? :force_encoding
899
+ assert_equal expected, h.params['filename']
881
900
  end
882
901
 
883
902
  def test_disposition=
@@ -916,20 +935,24 @@ class ContentDispositionHeaderTester < Test::Unit::TestCase
916
935
  def test_should_return_the_evelope_sender_when_given_from_without_a_colon
917
936
  p = TMail::FilePort.new("#{File.dirname(__FILE__)}/fixtures/mailbox")
918
937
  h = TMail::HeaderField.new_from_port(p, 'EnvelopeSender')
919
- assert_equal("mike@envelope_sender.com.au", h.addrs.to_s)
938
+ assert_equal("mike@envelope_sender.com.au", h.addrs.join)
920
939
  end
921
940
 
922
941
  def test_new_from_port_should_produce_a_header_object_that_contains_the_right_data
923
942
  p = TMail::FilePort.new("#{File.dirname(__FILE__)}/fixtures/mailbox")
924
943
  h = TMail::HeaderField.new_from_port(p, 'From')
925
- assert_equal("Mikel Lindsaar <mikel@from_address.com>", h.addrs.to_s)
944
+ assert_equal("Mikel Lindsaar <mikel@from_address.com>", h.addrs.join)
926
945
  end
927
946
 
928
947
  def test_unwrapping_a_long_header_field_using_new_from_port
929
948
  p = TMail::FilePort.new("#{File.dirname(__FILE__)}/fixtures/mailbox")
930
- h = TMail::HeaderField.new_from_port(p, 'Received')
931
- line = "from mikel091a by oaamta05sl.mx.bigpond.com with SMTP id <20071021093820.JFMT24025.oaamta05sl.mx.bigpond.com@mikel091a> for <mikel@nowhere.com.else>; Sun, 21 Oct 2007 19:38:20 +1000"
932
- assert_equal(h.to_s, line)
949
+ h = TMail::HeaderField.new_from_port(p, 'Content-Type')
950
+ line = 'multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-42-587703407; micalg=sha1'
951
+ assert(line =~ /multipart\/signed/)
952
+ assert(line =~ /protocol="application\/pkcs7-signature"/)
953
+ assert(line =~ /boundary=Apple-Mail-42-587703407/)
954
+ assert(line =~ /micalg=sha1/)
955
+ assert_equal(line.length, 103)
933
956
  end
934
957
 
935
958
  def test_returning_nil_if_there_is_no_match