Skip to content

Commit 2a85ac1

Browse files
nobunevans
authored andcommitted
Fix NoMethodError when "qop" is not present
1 parent 63ebe2f commit 2a85ac1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/net/imap/authenticators/digest_md5.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def process(challenge)
2626
sparams[k] = v
2727
end
2828

29-
raise Net::IMAP::DataFormatError, "Bad Challenge: '#{challenge}'" unless c.eos?
29+
raise Net::IMAP::DataFormatError, "Bad Challenge: '#{challenge}'" unless c.eos? and sparams['qop']
3030
raise Net::IMAP::Error, "Server does not support auth (qop = #{sparams['qop'].join(',')})" unless sparams['qop'].include?("auth")
3131

3232
response = {

test/net/imap/test_imap_authenticators.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,11 @@ def test_digest_md5_authenticator_garbage
160160
auth.process('.')
161161
end
162162
end
163+
164+
def test_digest_md5_authenticator_no_qop
165+
auth = digest_md5("user", "pass")
166+
assert_raise(Net::IMAP::DataFormatError) do
167+
auth.process('Qop=""')
168+
end
169+
end
163170
end

0 commit comments

Comments
 (0)