ultra7 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +2 -0
- data/README.md +5 -4
- data/lib/ultra7/mime.rb +4 -4
- data/lib/ultra7/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b3d743cab74270eb2689c1d2f0bdfa870d34556
|
4
|
+
data.tar.gz: ff87b1329b6d69f7152d27b7e015bdba3ef017c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 914d2bc423738e3b25e14d1d51e8f10562a39a0b2f9fb07936075169b060c5032528944a4889d0480fbceb6935237a32f6e5fd2f0278dfe8dc03914cdd84dd99
|
7
|
+
data.tar.gz: f0918fb057780da088754f04b4bcc560e678c10292e59bb5203698c95e1b1cdf6045163e3df9f04d6479ce0379cd5623c2dd75f0f1c3b964babaa310e0bef004
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -3,9 +3,9 @@ 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
|
7
|
-
which is meant for decoding mailbox names.
|
8
|
-
* `Ultra7::MIME` is also a
|
6
|
+
* Ultra7 is a UTF-7 decoder for MIME message header names and values, per the MIME [encoded word syntax of RFC-2047](http://tools.ietf.org/html/rfc2047),
|
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), which is meant for decoding mailbox names.
|
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).
|
11
11
|
* Learn more about [Ultra7 at bitbucket](https://bitbucket.org/buruzaemon/ultra7/).
|
@@ -25,7 +25,7 @@ which is meant for decoding mailbox names.
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
* Using Ultra7 is pretty straight-forward, really. It _only_
|
28
|
+
* Using Ultra7 is pretty straight-forward, really. It _only_ decodes UTF-7.
|
29
29
|
|
30
30
|
require 'ultra7'
|
31
31
|
|
@@ -43,6 +43,7 @@ which is meant for decoding mailbox names.
|
|
43
43
|
Ultra7::MIME.decode_utf7(subject, encoding: 'UTF-8')
|
44
44
|
=> "배달 상태 알림(실패)"
|
45
45
|
|
46
|
+
|
46
47
|
* And you can use `Ultra7::MIME` as a mixin.
|
47
48
|
|
48
49
|
# As a mixin to another class
|
data/lib/ultra7/mime.rb
CHANGED
@@ -18,18 +18,18 @@ module Ultra7
|
|
18
18
|
# @param [Hash] options
|
19
19
|
# @return [String] UTF-7 decoded value
|
20
20
|
# @raise [ArgumentError] if text other than UTF-7 are passed in, or the given `encoding` cannot be found
|
21
|
-
# convert UTF-7
|
22
21
|
def self.decode_utf7(text, options={encoding: nil})
|
23
22
|
# only deal with UTF-7 encoding
|
24
|
-
text.scan(/=\?(.*)\?[
|
23
|
+
text.scan(/=\?(.*)\?[q]\?/i).each {
|
25
24
|
e = $1
|
26
25
|
if e and !(e=~/utf\-7/i)
|
27
26
|
raise ArgumentError.new("Cannot decode #{e} as UTF-7!")
|
28
27
|
end
|
29
28
|
}
|
30
29
|
|
31
|
-
# remove any encoding start/end markers
|
32
|
-
|
30
|
+
# remove any opening charset and Q-encoding start/end markers
|
31
|
+
# for MIME encoded words
|
32
|
+
text = text.gsub(/\?=/, '').gsub(/=\?[^?]*utf\-7\?[q]\?/i, '')
|
33
33
|
|
34
34
|
enc = options[:encoding].nil? \
|
35
35
|
? Encoding.default_external \
|
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.3.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-14 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).
|