mail-iso-2022-jp 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mail-iso-2022-jp/patches.rb +46 -6
- metadata +63 -84
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'mail'
|
4
4
|
require 'base64'
|
5
|
+
require 'nkf'
|
5
6
|
|
6
7
|
module Mail
|
7
8
|
WAVE_DASH = "〜" # U+301C
|
@@ -15,7 +16,23 @@ module Mail
|
|
15
16
|
NKF_OPTIONS = "--oc=CP50220 -xj"
|
16
17
|
end
|
17
18
|
|
19
|
+
class InvalidEncodingError < StandardError; end
|
20
|
+
|
18
21
|
class Message
|
22
|
+
def body_with_iso_2022_jp_encoding=(value)
|
23
|
+
if @charset.to_s.downcase == 'iso-2022-jp'
|
24
|
+
if RUBY_VERSION >= '1.9'
|
25
|
+
if value.respond_to?(:encoding) && value.encoding.to_s != 'UTF-8'
|
26
|
+
raise ::Mail::InvalidEncodingError.new(
|
27
|
+
"The mail body is not encoded in UTF-8 but in #{value.encoding}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
self.body_without_iso_2022_jp_encoding = value
|
32
|
+
end
|
33
|
+
alias_method :body_without_iso_2022_jp_encoding=, :body=
|
34
|
+
alias_method :body=, :body_with_iso_2022_jp_encoding=
|
35
|
+
|
19
36
|
def process_body_raw_with_iso_2022_jp_encoding
|
20
37
|
if @charset.to_s.downcase == 'iso-2022-jp'
|
21
38
|
@body_raw = @body_raw.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
|
@@ -51,7 +68,23 @@ module Mail
|
|
51
68
|
alias_method :initialize_without_iso_2022_jp_encoding, :initialize
|
52
69
|
alias_method :initialize, :initialize_with_iso_2022_jp_encoding
|
53
70
|
end
|
54
|
-
|
71
|
+
|
72
|
+
class Field
|
73
|
+
def initialize_with_iso_2022_jp_encoding(name, value = nil, charset = 'utf-8')
|
74
|
+
if charset == 'ISO-2022-JP' && value.kind_of?(String)
|
75
|
+
if RUBY_VERSION >= '1.9'
|
76
|
+
unless [ 'UTF-8', 'US-ASCII' ].include?(value.encoding.to_s)
|
77
|
+
raise ::Mail::InvalidEncodingError.new(
|
78
|
+
"The '#{name}' field is not encoded in UTF-8 nor in US-ASCII but in #{value.encoding}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
initialize_without_iso_2022_jp_encoding(name, value, charset)
|
83
|
+
end
|
84
|
+
alias_method :initialize_without_iso_2022_jp_encoding, :initialize
|
85
|
+
alias_method :initialize, :initialize_with_iso_2022_jp_encoding
|
86
|
+
end
|
87
|
+
|
55
88
|
module FieldWithIso2022JpEncoding
|
56
89
|
def self.included(base)
|
57
90
|
base.send :alias_method, :initialize_without_iso_2022_jp_encoding, :initialize
|
@@ -79,7 +112,7 @@ module Mail
|
|
79
112
|
do_decode_without_iso_2022_jp_encoding
|
80
113
|
end
|
81
114
|
end
|
82
|
-
|
115
|
+
|
83
116
|
def encode_with_iso_2022_jp(value, charset)
|
84
117
|
value = value.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
|
85
118
|
if RUBY_VERSION >= '1.9'
|
@@ -96,13 +129,13 @@ module Mail
|
|
96
129
|
def b_value_encode(string)
|
97
130
|
string.split(' ').map do |s|
|
98
131
|
if s =~ /\e/
|
99
|
-
|
132
|
+
encode64(s)
|
100
133
|
else
|
101
134
|
s
|
102
135
|
end
|
103
136
|
end.join(" ")
|
104
137
|
end
|
105
|
-
|
138
|
+
|
106
139
|
private
|
107
140
|
def encode(value)
|
108
141
|
if charset.to_s.downcase == 'iso-2022-jp'
|
@@ -111,17 +144,24 @@ module Mail
|
|
111
144
|
super(value)
|
112
145
|
end
|
113
146
|
end
|
114
|
-
|
147
|
+
|
115
148
|
def encode_crlf(value)
|
116
149
|
if RUBY_VERSION >= '1.9' && charset.to_s.downcase == 'iso-2022-jp'
|
117
150
|
value.force_encoding('ascii-8bit')
|
118
151
|
end
|
119
152
|
super(value)
|
120
153
|
end
|
154
|
+
|
155
|
+
def encode64(string)
|
156
|
+
"=?ISO-2022-JP?B?#{Base64.encode64(string).gsub("\n", "")}?="
|
157
|
+
end
|
121
158
|
end
|
122
|
-
|
159
|
+
|
123
160
|
class SubjectField < UnstructuredField
|
124
161
|
include FieldWithIso2022JpEncoding
|
162
|
+
def b_value_encode(string)
|
163
|
+
encode64(string)
|
164
|
+
end
|
125
165
|
end
|
126
166
|
|
127
167
|
class FromField < StructuredField
|
metadata
CHANGED
@@ -1,126 +1,105 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-iso-2022-jp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.8
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 7
|
10
|
-
version: 1.1.7
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Kohei MATSUSHITA
|
14
9
|
- Tsutomu KURODA
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
23
16
|
name: mail
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
hash: 13
|
31
|
-
segments:
|
32
|
-
- 2
|
33
|
-
- 2
|
34
|
-
- 5
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
35
22
|
version: 2.2.5
|
36
23
|
- - <=
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
hash: 23
|
39
|
-
segments:
|
40
|
-
- 2
|
41
|
-
- 4
|
42
|
-
- 4
|
24
|
+
- !ruby/object:Gem::Version
|
43
25
|
version: 2.4.4
|
44
26
|
type: :runtime
|
45
|
-
version_requirements: *id001
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: actionmailer
|
48
27
|
prerelease: false
|
49
|
-
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.5
|
34
|
+
- - <=
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.4.4
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: actionmailer
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
50
40
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
hash: 7
|
55
|
-
segments:
|
56
|
-
- 3
|
57
|
-
- 0
|
58
|
-
- 0
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
59
44
|
version: 3.0.0
|
60
45
|
type: :development
|
61
|
-
version_requirements: *id002
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rdoc
|
64
46
|
prerelease: false
|
65
|
-
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rdoc
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
66
56
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
segments:
|
72
|
-
- 3
|
73
|
-
- 12
|
74
|
-
version: "3.12"
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.12'
|
75
61
|
type: :development
|
76
|
-
|
77
|
-
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
69
|
+
description: A set of patches for mikel's mail gem. With this, you can easily send
|
70
|
+
and receive mails with ISO-2022-JP enconding (so-called 'JIS-CODE').
|
78
71
|
email: hermes@oiax.jp
|
79
72
|
executables: []
|
80
|
-
|
81
73
|
extensions: []
|
82
|
-
|
83
74
|
extra_rdoc_files: []
|
84
|
-
|
85
|
-
files:
|
75
|
+
files:
|
86
76
|
- README.md
|
87
77
|
- Gemfile
|
88
78
|
- Rakefile
|
89
79
|
- lib/mail-iso-2022-jp/patches.rb
|
90
80
|
- lib/mail-iso-2022-jp.rb
|
91
|
-
has_rdoc: true
|
92
81
|
homepage: https://github.com/kuroda/mail-iso-2022-jp
|
93
82
|
licenses: []
|
94
|
-
|
95
83
|
post_install_message:
|
96
84
|
rdoc_options: []
|
97
|
-
|
98
|
-
require_paths:
|
85
|
+
require_paths:
|
99
86
|
- lib
|
100
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
88
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
|
107
|
-
- 0
|
108
|
-
version: "0"
|
109
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
94
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
version: "0"
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
118
99
|
requirements: []
|
119
|
-
|
120
100
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.8.23
|
122
102
|
signing_key:
|
123
103
|
specification_version: 3
|
124
|
-
summary: A
|
104
|
+
summary: A set of patches that provides 'mail' gem with iso-2022-jp conversion capability.
|
125
105
|
test_files: []
|
126
|
-
|