Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Shouldn't be fooled into encoding strings on 1.8 by unrelated Encodin…

…g constant

Fixes #478
  • Loading branch information...
commit 6f12f7e1c00a5cddfe92c35430ac0719e414a16e 1 parent 8b3f4e2
@jeremy jeremy authored
View
1  CHANGELOG.rdoc
@@ -12,6 +12,7 @@ Performance:
* Close pull request 488 - Speed up field construction & comparison (bpot)
Bugs:
+* Shouldn't be fooled into encoding strings on 1.8 by unrelated Encoding constant (emiellohr, jeremy)
* Header encoding should be US-ASCII, not the default external encoding (jeremy)
* Address elements should return decoded display names by default (jeremy)
* Fix up tests that depend on utf-8 external encoding; read fixtures as binary (jeremy)
View
2  lib/mail/fields/unstructured_field.rb
@@ -146,7 +146,7 @@ def fold(prepend = 0) # :nodoc:
line = ""
while !words.empty?
break unless word = words.first.dup
- word.encode!(charset) if defined?(Encoding) && charset
+ word.encode!(charset) if charset && word.respond_to?(:encode!)
word = encode(word) if should_encode
word = encode_crlf(word)
# Skip to next line if we're going to go past the limit
View
11 spec/mail/fields/unstructured_field_spec.rb
@@ -102,6 +102,17 @@
@field.encoded.gsub("UTF-8", "UTF8").should eq result
@field.decoded.should eq string
end
+
+ if !'1.9'.respond_to?(:force_encoding)
+ it "shouldn't get fooled into encoding on 1.8 due to an unrelated Encoding constant" do
+ begin
+ Mail::UnstructuredField::Encoding = 'derp'
+ @field.encoded.should eq "Subject: Hello Frank\r\n"
+ ensure
+ Mail::UnstructuredField.send :remove_const, :Encoding
+ end
+ end
+ end
end
describe "folding" do

0 comments on commit 6f12f7e

Please sign in to comment.
Something went wrong with that request. Please try again.