Skip to content

Commit

Permalink
Merge branch 'master' of github.com:daveslutzkin/mail
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Nov 10, 2013
2 parents b6a1d60 + 1a27e0f commit 148819f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/mail/utilities.rb
Expand Up @@ -21,7 +21,9 @@ def quote_phrase( str )
original_encoding = str.encoding
str.force_encoding('ASCII-8BIT')
if (PHRASE_UNSAFE === str)
dquote(str).force_encoding(original_encoding)
quoted_str = dquote(str).force_encoding(original_encoding)
str.force_encoding(original_encoding)
quoted_str
else
str.force_encoding(original_encoding)
end
Expand Down
26 changes: 26 additions & 0 deletions spec/mail/utilities_spec.rb
Expand Up @@ -83,6 +83,32 @@

end

if RUBY_VERSION >= '1.9'
describe "quoting phrases" do
describe "given a non-unsafe string" do
it "should not change the encoding" do
input_str = "blargh"
input_str_encoding = input_str.encoding

quote_phrase(input_str)

input_str.encoding.should eq input_str_encoding
end
end

describe "given an unsafe string" do
it "should not change the encoding" do
input_str = "Bjørn"
input_str_encoding = input_str.encoding

quote_phrase(input_str)

input_str.encoding.should eq input_str_encoding
end
end
end
end

describe "escaping parenthesies" do
it "should escape parens" do
test = 'This is not (escaped)'
Expand Down

0 comments on commit 148819f

Please sign in to comment.