mail-iso-2022-jp 2.0.0.pre → 2.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,20 +22,23 @@ Feature
22
22
 
23
23
  * (en)
24
24
 
25
- If you set the `charset` header to `ISO-2022-JP`, the values of `From`, `Sender`, `To`, `Cc`,
25
+ * If you set the `charset` header to `ISO-2022-JP`, the values of `From`, `Sender`, `To`, `Cc`,
26
26
  `Reply-To`, `Subject`, `Resent-From`, `Resent-Sender`, `Resent-To` and `Resent-Cc` headers
27
27
  and the text of body will be automatically converted to `ISO-2022-JP`.
28
-
29
- When the `charset` header has other values, this patch has no effect.
28
+
29
+ * The text part of multipart mail is also encoded with iso-2022-jp.
30
+
31
+ * When the `charset` header has other values, this patch has no effect.
30
32
 
31
33
  * (ja)
32
34
 
33
- chasetヘッダの値が `ISO-2022-JP` である場合、差出人(From)、Sender、宛先(To)、Cc、Reply-To、件名(Subject)、
35
+ * chasetヘッダの値が `ISO-2022-JP` である場合、差出人(From)、Sender、宛先(To)、Cc、Reply-To、件名(Subject)、
34
36
  Resent-From、Resent-Sender、Resent-To、Resent-Cc の各ヘッダの値および本文(Body)が
35
37
  自動的に `ISO-2022-JP` に変換されます。
36
-
37
- charsetヘッダの値が `ISO-2022-JP` でない場合、このパッチには何の効果もありません。
38
38
 
39
+ * マルチパートメールのテキストパートもiso-2022-jpでエンコードされます。
40
+
41
+ * charsetヘッダの値が `ISO-2022-JP` でない場合、このパッチには何の効果もありません。
39
42
 
40
43
  Requirements
41
44
  ------------
@@ -48,7 +51,7 @@ Requirements
48
51
 
49
52
  * `mail` 2.2.6 or higher, but lower than or equal to 2.5.3
50
53
 
51
- ### Ruby on Rails (Optional) ###
54
+ ### ActionMailer (Optional) ###
52
55
 
53
56
  * 3.0 or higher
54
57
 
@@ -113,18 +116,19 @@ Remarks
113
116
  -------
114
117
 
115
118
  * (en)
116
- * NEC special characters like `①` and IBM extended characters like `髙`, `﨑` are allowed in the subject, recipient names and mail body.
117
- * Fullwidth tildes (U+FF5E) are translated into wave dashes (U+301C).
118
- * Half-width (Hankaku) katakanas are maintained intact.
119
+ * NEC special characters like `①` and IBM extended characters like `髙`, `﨑`
120
+ are allowed in the subject, recipient names and mail body.
121
+ * Fullwidth tilde (U+FF5E) and wave dashe (U+301C) are converted to the fullwidth tilde (2141).
122
+ * Fullwidth hyphen minus (U+FF0D) and minus sign (U+2212) are converted to the fullwidth minus (215D).
123
+ * Halfwidth (Hankaku) katakanas are maintained intact.
119
124
  * Characters that cannot be translated into iso-2022-jp encoding are substituted with question marks (`?`).
120
- * The text part of multipart mail is also encoded with iso-2022-jp.
121
125
 
122
126
  * (ja)
123
127
  * `①` などのNEC特殊文字や `髙` や `﨑` といったIBM拡張文字を件名、宛先、本文などに含めることができます。
124
- * 全角チルダ(U+FF5E)は波ダッシュ(U+301C)に変換されます。
128
+ * 全角チルダ(U+FF5E)と波ダッシュ(U+301C)は、全角チルダ(2141)に変換されます。
129
+ * 全角ハイフンマイナス(U+ff0D)とマイナス記号(U+2212)は、全角マイナス(215D)に変換されます。
125
130
  * 半角カタカナはそのまま維持されます。
126
131
  * 変換できない文字は疑問符(`?`)で置換されます。
127
- * マルチパートメールのテキストパートもiso-2022-jpでエンコードされます。
128
132
 
129
133
  References
130
134
  ----------
@@ -11,4 +11,5 @@ else
11
11
  end
12
12
 
13
13
  require 'mail-iso-2022-jp/header'
14
- require 'mail-iso-2022-jp/fields'
14
+ require 'mail-iso-2022-jp/subject_field'
15
+ require 'mail-iso-2022-jp/structured_fields'
@@ -34,6 +34,7 @@ module Mail
34
34
 
35
35
  def encode_with_iso_2022_jp(value, charset)
36
36
  value = value.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
37
+ value = value.to_s.gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS)
37
38
  value = Mail.encoding_to_charset(value, charset)
38
39
  value.force_encoding('ascii-8bit')
39
40
  value = b_value_encode(value)
@@ -1,9 +1,11 @@
1
1
  # coding: utf-8
2
2
 
3
- # Patches for Mail on Ruby 1.8.7
3
+ # Patches for Mail on Ruby 1.9.3 or above
4
4
  module Mail
5
5
  WAVE_DASH = "〜" # U+301C
6
6
  FULLWIDTH_TILDE = "~" # U+FF5E
7
+ MINUS_SIGN = [0x2212].pack("U")
8
+ FULLWIDTH_HYPHEN_MINUS = [0xff0d].pack("U")
7
9
  ENCODE = { 'iso-2022-jp' => Encoding::CP50221 }
8
10
 
9
11
  def self.encoding_to_charset(str, charset)
@@ -11,6 +11,7 @@ module Mail
11
11
  raise ::Mail::InvalidEncodingError.new(
12
12
  "The mail body is not encoded in UTF-8 but in #{value.encoding}")
13
13
  end
14
+ value = value.gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS)
14
15
  end
15
16
  self.body_without_iso_2022_jp_encoding = value
16
17
  end
@@ -35,6 +35,7 @@ module Mail
35
35
 
36
36
  def encode_with_iso_2022_jp(value)
37
37
  value = value.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
38
+ value = value.to_s.gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS)
38
39
  value = NKF.nkf(NKF_OPTIONS, value)
39
40
  b_value_encode(value)
40
41
  end
@@ -1,9 +1,11 @@
1
1
  # coding: utf-8
2
2
 
3
- # Patches for Mail on Ruby 1.9.x or above
3
+ # Patches for Mail on Ruby 1.8.7
4
4
  module Mail
5
5
  WAVE_DASH = "〜" # U+301C
6
6
  FULLWIDTH_TILDE = "~" # U+FF5E
7
+ MINUS_SIGN = [0x2212].pack("U")
8
+ FULLWIDTH_HYPHEN_MINUS = [0xff0d].pack("U")
7
9
  NKF_OPTIONS = "--oc=CP50220 -xjW --fb-subchar"
8
10
 
9
11
  class InvalidEncodingError < StandardError; end
@@ -15,6 +15,7 @@ module Mail
15
15
  def process_body_raw_with_iso_2022_jp_encoding
16
16
  if @charset.to_s.downcase == 'iso-2022-jp'
17
17
  @body_raw = @body_raw.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
18
+ @body_raw = @body_raw.to_s.gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS)
18
19
  @body_raw = NKF.nkf(NKF_OPTIONS, @body_raw)
19
20
  end
20
21
  process_body_raw_without_iso_2022_jp_encoding
@@ -3,13 +3,6 @@
3
3
  require 'mail'
4
4
 
5
5
  module Mail
6
- class SubjectField < UnstructuredField
7
- include FieldWithIso2022JpEncoding
8
- def b_value_encode(string)
9
- encode64(string)
10
- end
11
- end
12
-
13
6
  class FromField < StructuredField
14
7
  include FieldWithIso2022JpEncoding
15
8
  end
@@ -0,0 +1,12 @@
1
+ # coding:utf-8
2
+
3
+ require 'mail'
4
+
5
+ module Mail
6
+ class SubjectField < UnstructuredField
7
+ include FieldWithIso2022JpEncoding
8
+ def b_value_encode(string)
9
+ encode64(string)
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-iso-2022-jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre
4
+ version: 2.0.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-20 00:00:00.000000000 Z
13
+ date: 2013-01-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mail
@@ -83,7 +83,8 @@ files:
83
83
  - lib/mail-iso-2022-jp/ruby18/field_with_iso_2022_jp_encoding.rb
84
84
  - lib/mail-iso-2022-jp/ruby18/mail.rb
85
85
  - lib/mail-iso-2022-jp/field_with_iso_2022_jp_encoding.rb
86
- - lib/mail-iso-2022-jp/fields.rb
86
+ - lib/mail-iso-2022-jp/subject_field.rb
87
+ - lib/mail-iso-2022-jp/structured_fields.rb
87
88
  - lib/mail-iso-2022-jp/header.rb
88
89
  - lib/mail-iso-2022-jp/mail.rb
89
90
  - lib/mail-iso-2022-jp.rb
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  version: 1.3.1
108
109
  requirements: []
109
110
  rubyforge_project:
110
- rubygems_version: 1.8.24
111
+ rubygems_version: 1.8.23
111
112
  signing_key:
112
113
  specification_version: 3
113
114
  summary: A set of patches that provides 'mail' gem with iso-2022-jp conversion capability.