rfc2047 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +1 -1
  2. data/lib/rfc2047.rb +4 -1
  3. metadata +3 -3
data/README.md CHANGED
@@ -12,4 +12,4 @@ It was originally written by Sam Roberts in 2003, and the current version was ta
12
12
  [3]: http://dev.joyent.com/projects/connector/browse/trunk/vendor/rfc2047.rb
13
13
  [4]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/69323
14
14
  [5]: https://rubygems.org/gems/rfc2047
15
- [6]: https://www.github.com/ConradIrwin/rfc2047-ruby/
15
+ [6]: https://www.github.com/ConradIrwin/rfc2047-ruby
data/lib/rfc2047.rb CHANGED
@@ -16,12 +16,15 @@ module Rfc2047
16
16
 
17
17
  WORD = /=\?([!#$\%&'*+-\/0-9A-Z\\^\`a-z{|}~]+)\?([BbQq])\?([!->@-~]+)\?=/ # :nodoc:
18
18
 
19
+ # Look for two adjacent words in the same encoding.
20
+ ADJACENT_WORDS = /(#{WORD})[\s\r\n]+(?==\?(\2)\?([BbQq])\?)/
21
+
19
22
  # Decodes a string, +from+, containing RFC 2047 encoded words into a target
20
23
  # character set, +target+ defaulting to utf-8. See iconv_open(3) for information on the
21
24
  # supported target encodings. If one of the encoded words cannot be
22
25
  # converted to the target encoding, it is left in its encoded form.
23
26
  def self.decode(from, target='utf-8')
24
- from.gsub(WORD) do |word|
27
+ from.gsub(ADJACENT_WORDS, "\\1").gsub(WORD) do |word|
25
28
  cs = $1
26
29
  encoding = $2
27
30
  text = $3
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- version: "0.1"
7
+ - 2
8
+ version: "0.2"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Sam Roberts
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-09 00:00:00 -07:00
17
+ date: 2011-04-10 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20