Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable UTF8=ACCEPT if the server supports ENABLE (and UTF=ACCEPT). #1617

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/mail/network/retriever_methods/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def start(config=Mail::Configuration.instance, &block)
imap.authenticate(settings[:authentication], settings[:user_name], settings[:password])
end

imap.enable :utf8 if imap.capable?("ENABLE")

yield imap
ensure
if defined?(imap) && imap && !imap.disconnected?
Expand Down
13 changes: 13 additions & 0 deletions spec/mail/network/retriever_methods/imap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,18 @@
end
end


describe "UTF8=ACCEPT support" do
before(:each) do
@imap = MockIMAP.new
allow(MockIMAP).to receive(:new).and_return(@imap)
allow(@imap).to receive(:capable?).with("ENABLE").and_return(true)
end
it "should enable UTF8=ACCEPT" do
expect(@imap).to receive(:enable).with(:utf8)
messages = Mail.find
end
end

end

4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def expunge
@@marked_for_deletion = []
end

def capable?(name)
false
end

def self.mailbox; @@mailbox end # test only
def self.readonly?; @@readonly end # test only

Expand Down