mail-jdec 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/mail/jdec/elements/message_ids_element_patch.rb +20 -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 +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b79e3c592167bea0b81f1f92959a728b253f27b9a4ac84cbfca9c24af70bf44
|
4
|
+
data.tar.gz: 5c2205ef8533ade4e48367f0b72cea2a7c39b41e470aa6925bda3122cf8da0b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a900a989980cd0d098dd5376ddd0c58f02e51b8b781194978d34e6b5febaf4b144ce0c0a2dea4269dad77d27c870780ad901e4e4d9c205d70e806dd525716571
|
7
|
+
data.tar.gz: 200f37329d5a89d19a8690f13f07dac5eb96d32aba0ee5a4e4f893c75c5ff7dcdfdb3a0b58fcf4cea2077ae83c1dcc4d991861592a3ff10fb580499f8b3e6da9
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mail
|
4
|
+
module Jdec
|
5
|
+
module MessageIdsElementPatch
|
6
|
+
private
|
7
|
+
|
8
|
+
def parse(string)
|
9
|
+
if Jdec.enabled? && string.is_a?(String)
|
10
|
+
string = string.gsub(/\t/, ' ')
|
11
|
+
end
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
unless Mail::MessageIdsElement.included_modules.include?(Mail::Jdec::MessageIdsElementPatch)
|
19
|
+
Mail::MessageIdsElement.prepend Mail::Jdec::MessageIdsElementPatch
|
20
|
+
end
|
@@ -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.2
|
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-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/mail/jdec/detector.rb
|
105
105
|
- lib/mail/jdec/elements/content_disposition_element_patch.rb
|
106
106
|
- lib/mail/jdec/elements/content_type_element_patch.rb
|
107
|
+
- lib/mail/jdec/elements/message_ids_element_patch.rb
|
107
108
|
- lib/mail/jdec/encodings_patch.rb
|
108
109
|
- lib/mail/jdec/fields/common_address_field_patch.rb
|
109
110
|
- lib/mail/jdec/fields/common_date_field_patch.rb
|
@@ -132,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
133
|
- !ruby/object:Gem::Version
|
133
134
|
version: '0'
|
134
135
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.3.3
|
136
137
|
signing_key:
|
137
138
|
specification_version: 4
|
138
139
|
summary: A mail patch for decoding some improper mails
|