mail-jdec 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mail/jdec/message_patch.rb +20 -3
- data/lib/mail/jdec/version.rb +1 -1
- data/lib/mail/jdec.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4cba29f251d5a8fe9a696f6e965b9fd2b52c622f64aedb23f63567e3ebc15d0
|
4
|
+
data.tar.gz: ae6a610eee21b581f474fedf651a90e54bc9e5dde5d613daeebd621c0520da86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5a8e19b16e943c41890c0652433f1607b15c08108440dbbe0fbe4ca6e3360f3aed4d43328e46aa4230b390bac46b9566db890b123f675444972054231af7514
|
7
|
+
data.tar.gz: 9cd358e45c80af8aab96e8d995d16720028ec657c224a0faeb07ba2eec12b39be15b76f2c778524f4a420b499c7649eea13e751eeefdf55deb53dbf083f1549b
|
data/CHANGELOG.md
CHANGED
@@ -6,13 +6,13 @@ module Mail
|
|
6
6
|
def decoded
|
7
7
|
decoded = super
|
8
8
|
|
9
|
-
if Jdec.enabled? &&
|
9
|
+
if Jdec.enabled? && MessagePatch.autodetect?(self)
|
10
10
|
detected = Detector.detect(decoded)
|
11
11
|
if detected && detected[:type] == :text
|
12
12
|
charset = detected[:encoding].downcase
|
13
13
|
decoded = Mail::Encodings.transcode_charset(decoded.dup.force_encoding(charset), charset, 'utf-8')
|
14
|
-
header[:content_type] = 'text/plain'
|
15
|
-
header[:content_type].parameters[:charset] = charset
|
14
|
+
header[:content_type] = 'text/plain' unless has_content_type?
|
15
|
+
header[:content_type].parameters[:charset] = charset unless has_charset?
|
16
16
|
else
|
17
17
|
decoded = Mail::Encodings.transcode_charset(decoded, decoded.encoding, 'utf-8')
|
18
18
|
end
|
@@ -20,6 +20,23 @@ module Mail
|
|
20
20
|
|
21
21
|
decoded
|
22
22
|
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
def autodetect?(message)
|
26
|
+
!message.has_content_type? ||
|
27
|
+
(mime_types_for_autodetect?(message.mime_type) && !message.has_charset? && !message.attachment? && !message.multipart?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def mime_types_for_autodetect?(mime_type)
|
31
|
+
Jdec.mime_types_for_autodetect.any? do |type|
|
32
|
+
if type.is_a?(Regexp)
|
33
|
+
type.match?(mime_type)
|
34
|
+
else
|
35
|
+
type == mime_type
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
data/lib/mail/jdec/version.rb
CHANGED
data/lib/mail/jdec.rb
CHANGED
@@ -13,6 +13,7 @@ module Mail
|
|
13
13
|
attr_reader :enabled
|
14
14
|
attr_accessor :autodetect_confidence
|
15
15
|
attr_accessor :autodetect_skip_charsets
|
16
|
+
attr_accessor :mime_types_for_autodetect
|
16
17
|
attr_accessor :preferred_charsets
|
17
18
|
|
18
19
|
def enabled?
|
@@ -31,6 +32,7 @@ module Mail
|
|
31
32
|
self.enable
|
32
33
|
self.autodetect_confidence = 50
|
33
34
|
self.autodetect_skip_charsets = %w()
|
35
|
+
self.mime_types_for_autodetect = [%r{^text/}, 'message/delivery-status', 'message/disposition-notification']
|
34
36
|
self.preferred_charsets = {
|
35
37
|
'iso-2022-jp' => 'cp50221',
|
36
38
|
'iso-2022-jp-1' => 'cp50221',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-jdec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshikazu Kaneta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
135
|
+
rubygems_version: 3.3.3
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: A mail patch for decoding some improper mails
|