ultra7 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/README.md +7 -7
- data/lib/ultra7/mime.rb +12 -13
- data/lib/ultra7/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a3e1cae83da627a5d3d9e1ad0147e6f7521ca1
|
4
|
+
data.tar.gz: fa0a08df7b4028b3835725858e131244f25aea28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 132176393aa4a6a2bc42bd744e4fdf73205af9b99d200b48980c07619631b4cc69a4078e9c849a452e139882a6dd46d5387febafaab1d815dc7a1bfe70f76525
|
7
|
+
data.tar.gz: 761e5694be3f35cc2cb368a0b9bcddb44564bfc6843f6b3e43bbbed8e800b8d2bc192fe7f1118e01068dfb3cfb17b3ac3fbcd9823bde5e7d9b9e3504e6b69220
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
|
3
|
+
- __2014/12/17__: 0.5.0 release.
|
4
|
+
- Enhanced handling for multi-line string input.
|
5
|
+
- Minor documentation edits for clarity.
|
6
|
+
|
7
|
+
- __2014/12/14__: 0.4.0 release.
|
8
|
+
- Very minor documentation corrections.
|
9
|
+
|
3
10
|
- __2014/12/14__: 0.3.0 release.
|
4
11
|
- Slight enhancement to MIME encoded-word handling.
|
5
12
|
|
data/README.md
CHANGED
@@ -3,8 +3,8 @@ A UTF-7 MIME header decoder, plain and simple.
|
|
3
3
|
|
4
4
|
## What is Ultra7?
|
5
5
|
|
6
|
-
* Ultra7 is a UTF-7 decoder for MIME message
|
7
|
-
* It is almost unlike [`Net::IMAP.decode_utf7`](http://ruby-doc.org/stdlib-2.0.0/libdoc/net/imap/rdoc/Net/IMAP.html#method-c-decode_utf7)
|
6
|
+
* Ultra7 is a UTF-7 decoder for MIME message headers, per the [MIME encoded word syntax of RFC-2047](http://tools.ietf.org/html/rfc2047).
|
7
|
+
* It is almost, but not quite, *completely unlike [`Net::IMAP.decode_utf7`](http://ruby-doc.org/stdlib-2.0.0/libdoc/net/imap/rdoc/Net/IMAP.html#method-c-decode_utf7)*, which is meant for decoding *mailbox names*. Ultra7 only does MIME message headers.
|
8
8
|
* `Ultra7::MIME` is also a mixin, so you can conveniently combine it in another class by using
|
9
9
|
`include`.
|
10
10
|
* Read the [API documentation](http://www.rubydoc.info/gems/ultra7).
|
@@ -33,12 +33,12 @@ A UTF-7 MIME header decoder, plain and simple.
|
|
33
33
|
puts Ultra7::MIME.decode_utf7('1 +- 1 = 2')
|
34
34
|
=> "1 + 1 = 2"
|
35
35
|
|
36
|
-
#
|
36
|
+
# Decodes UTF-7, returning string with default encoding
|
37
37
|
puts Ultra7::MIME.decode_utf7('Hello, +ZeVnLIqe-')
|
38
38
|
=> "Hello, 日本語"
|
39
|
-
|
40
|
-
#
|
41
|
-
#
|
39
|
+
|
40
|
+
# Decodes an actual Subject MIME header in UTF-7,
|
41
|
+
# returning string with explicit UTF-8 encoding
|
42
42
|
subject = '=?unicode-1-1-utf-7?Q?+vDCy7A- +wMHQ3A- +xUy5vA-(+wuTTKA-)?='
|
43
43
|
Ultra7::MIME.decode_utf7(subject, encoding: 'UTF-8')
|
44
44
|
=> "배달 상태 알림(실패)"
|
@@ -74,4 +74,4 @@ A UTF-7 MIME header decoder, plain and simple.
|
|
74
74
|
Please see the {file:CHANGELOG} for this gem's release history.
|
75
75
|
|
76
76
|
## Copyright
|
77
|
-
Copyright © 2014-2015, Brooke M. Fujita. All rights reserved. Please see the {file:LICENSE} file for further details.
|
77
|
+
Copyright © 2014-2015, Brooke M. Fujita. All rights reserved. Please see the {file:LICENSE} file for further details.
|
data/lib/ultra7/mime.rb
CHANGED
@@ -8,22 +8,21 @@ module Ultra7
|
|
8
8
|
base.extend(ClassMethods)
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# Parse the given UTF-7 encoded-word text
|
12
|
+
# and return the corresponding decoded value.
|
13
|
+
#
|
14
|
+
# If the `:encoding` name is not specified in the `options`
|
14
15
|
# hash, then the resulting string will use the default
|
15
16
|
# `Encoding.default_external` encoding.
|
16
17
|
#
|
17
|
-
# @param [String] text UTF-7
|
18
|
+
# @param [String] text UTF-7 encoded-word text
|
18
19
|
# @param [Hash] options
|
19
|
-
# @
|
20
|
-
# @
|
21
|
-
#
|
22
|
-
|
23
|
-
# or if the encoding for the decoded value is not valid
|
24
|
-
def self.decode_utf7(text, options={encoding: nil})
|
20
|
+
# @return [String] UTF-7 decoded value
|
21
|
+
# @raise [ArgumentError] if text other than UTF-7 is passed in,
|
22
|
+
# or the named `:encoding` cannot be found
|
23
|
+
def self.decode_utf7(text, options={encoding: nil})
|
25
24
|
# only deal with UTF-7 encoding
|
26
|
-
text.scan(/=\?(.*)\?[q]\?/
|
25
|
+
text.scan(/=\?(.*)\?[q]\?/im).each {
|
27
26
|
e = $1
|
28
27
|
if e and !(e=~/utf\-7/i)
|
29
28
|
raise ArgumentError.new("Cannot decode #{e} as UTF-7!")
|
@@ -32,13 +31,13 @@ module Ultra7
|
|
32
31
|
|
33
32
|
# remove any opening charset and Q-encoding start/end markers
|
34
33
|
# for MIME encoded words
|
35
|
-
text = text.gsub(
|
34
|
+
text = text.gsub(/\?=/m, '').gsub(/=\?[^?]*utf\-7\?[q]\?/im, '')
|
36
35
|
|
37
36
|
enc = options[:encoding].nil? \
|
38
37
|
? Encoding.default_external \
|
39
38
|
: Encoding.find(options[:encoding])
|
40
39
|
|
41
|
-
return text.gsub(/\+(.*?)-/
|
40
|
+
return text.gsub(/\+(.*?)-/mn) {
|
42
41
|
if $1.empty?
|
43
42
|
"+"
|
44
43
|
else
|
data/lib/ultra7/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultra7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke M. Fujita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
ultra7 decodes UTF-7 in the context of MIME headers (c.f. https://tools.ietf.org/html/rfc2152).
|
@@ -17,7 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
-
|
20
|
+
- .yardopts
|
21
21
|
- CHANGELOG
|
22
22
|
- LICENSE
|
23
23
|
- README.md
|
@@ -34,17 +34,17 @@ require_paths:
|
|
34
34
|
- lib
|
35
35
|
required_ruby_version: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - '>='
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.9'
|
40
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - '>='
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
requirements: []
|
46
46
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.
|
47
|
+
rubygems_version: 2.4.1
|
48
48
|
signing_key:
|
49
49
|
specification_version: 4
|
50
50
|
summary: A UTF-7 MIME header decoder, plain and simple.
|