Skip to content

Commit

Permalink
Mail::Multibyte::Chars no longer changes the encoding of its argument
Browse files Browse the repository at this point in the history
Closes #1110
  • Loading branch information
jeremy committed May 22, 2017
1 parent 76e1881 commit b2be275
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ Bugs:
* #1023 - Fix double-quoting in display names. (garethrees)
* #1032 - Fix that comparing messages changed their raw Message-ID to their parsed message_id. (bobjflong)
* #1074 - Fix that the first address in a list is dropped when a subsequent address has non-US-ASCII characters. (domininik)
* #1107 - Fix Address#display_name and other formatting flip-flopping between
encoded and decoded forms depending on whether #encoded or #decoded was called
last. (jeremy)
* #1107 - Fix Address#display_name and other formatting flip-flopping between encoded and decoded forms depending on whether #encoded or #decoded was called last. (jeremy)
* #1110 - Fix that Mail::Multibyte::Chars#initialize mutated its argument by calling force_encoding on it. (jeremy)

== Version 2.6.4 - Wed Mar 23 08:16 -0700 2016 Jeremy Daer <jeremydaer@gmail.com>

Expand Down
2 changes: 1 addition & 1 deletion lib/mail/multibyte/chars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Chars
if RUBY_VERSION >= "1.9"
# Creates a new Chars instance by wrapping _string_.
def initialize(string)
@wrapped_string = string
@wrapped_string = string.dup
@wrapped_string.force_encoding(Encoding::UTF_8) unless @wrapped_string.frozen?
end
else
Expand Down
9 changes: 8 additions & 1 deletion spec/mail/multibyte_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
chars = Chars.new('VĚDA A VÝZKUM')
expect(chars.downcase).to eq("věda a výzkum")
end
end

if 'string'.respond_to?(:force_encoding)
it "doesn't mutate input string encoding" do
s = "ascii".force_encoding(Encoding::US_ASCII)
chars = Chars.new(s)
expect(s.encoding).to eq(Encoding::US_ASCII)
end
end
end

0 comments on commit b2be275

Please sign in to comment.