Skip to content

Commit

Permalink
Fix NoMethodError when "qop" is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and nevans committed Jul 26, 2023
1 parent 63ebe2f commit 2a85ac1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/net/imap/authenticators/digest_md5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def process(challenge)
sparams[k] = v
end

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

response = {
Expand Down
7 changes: 7 additions & 0 deletions test/net/imap/test_imap_authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,11 @@ def test_digest_md5_authenticator_garbage
auth.process('.')
end
end

def test_digest_md5_authenticator_no_qop
auth = digest_md5("user", "pass")
assert_raise(Net::IMAP::DataFormatError) do
auth.process('Qop=""')
end
end
end

0 comments on commit 2a85ac1

Please sign in to comment.