Skip to content

Commit 65218b9

Browse files
committed
Fix NoMethodError when "qop" is not present
1 parent 2024f3a commit 65218b9

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
@@ -146,4 +146,11 @@ def test_digest_md5_authenticator_garbage
146146
auth.process('.')
147147
end
148148
end
149+
150+
def test_digest_md5_authenticator_no_qop
151+
auth = digest_md5("user", "pass")
152+
assert_raise(Net::IMAP::DataFormatError) do
153+
auth.process('Qop=""')
154+
end
155+
end
149156
end

0 commit comments

Comments
 (0)