mhtml 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mhtml/document.rb +9 -2
- data/lib/mhtml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f4bc1a6b568ad1e1febef6b4478dcb1404c6244
|
4
|
+
data.tar.gz: 782098fd53cf5aba2cb30365778be234612cb395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7cab2a94057c38dd8cbfa0a0a83f43127d3f4266b3f91a2495b3335358a50f3f0414bf819dddb2b2f0cd901d1e420a4d99ff25daa216fafc6cbcf018e606a52
|
7
|
+
data.tar.gz: 46bce7e133c9ca26bae36fe4f26f1c7819931a85b1d9567d782742419be72d4c62416da0a86545c8f74848e5fad4dd1929fd44084350133461814ff92ac68747
|
data/lib/mhtml/document.rb
CHANGED
@@ -7,6 +7,7 @@ module Mhtml
|
|
7
7
|
attr_accessor :headers,
|
8
8
|
:body,
|
9
9
|
:is_quoted_printable,
|
10
|
+
:is_base_64,
|
10
11
|
:encoding,
|
11
12
|
:file_path,
|
12
13
|
:root_doc
|
@@ -16,6 +17,7 @@ module Mhtml
|
|
16
17
|
@header_key = nil
|
17
18
|
@header_value_lines = nil
|
18
19
|
@is_quoted_printable = false
|
20
|
+
@is_base_64 = false
|
19
21
|
@encoding = nil
|
20
22
|
|
21
23
|
@request = HttpParser::Parser.new_instance { |inst| inst.type = :response }
|
@@ -143,8 +145,12 @@ module Mhtml
|
|
143
145
|
elsif header.key == 'Content-Transfer-Encoding'
|
144
146
|
value = header.values.first
|
145
147
|
|
146
|
-
if !value.nil?
|
147
|
-
|
148
|
+
if !value.nil?
|
149
|
+
if value.value == 'quoted-printable'
|
150
|
+
@is_quoted_printable = true
|
151
|
+
elsif value.value == 'base64'
|
152
|
+
@is_base_64 = true
|
153
|
+
end
|
148
154
|
end
|
149
155
|
|
150
156
|
elsif header.key == 'Content-Location'
|
@@ -161,6 +167,7 @@ module Mhtml
|
|
161
167
|
|
162
168
|
def decode(str)
|
163
169
|
str = str.unpack1('M*') if @is_quoted_printable
|
170
|
+
str = Base64.decode64(str) if @is_base_64
|
164
171
|
str = str.force_encoding(@encoding) unless @encoding.nil?
|
165
172
|
str
|
166
173
|
end
|
data/lib/mhtml/version.rb
CHANGED