diff --git a/lib/net/imap/authenticators/digest_md5.rb b/lib/net/imap/authenticators/digest_md5.rb index b31bda4f..86aae605 100644 --- a/lib/net/imap/authenticators/digest_md5.rb +++ b/lib/net/imap/authenticators/digest_md5.rb @@ -15,7 +15,7 @@ def process(challenge) @stage = STAGE_TWO sparams = {} c = StringScanner.new(challenge) - while c.scan(/(?:\s*,)?\s*(\w+)=("(?:[^\\"]+|\\.)*"|[^,]+)\s*/) + while c.scan(/(?:\s*,)?\s*(\w+)=("(?:[^\\"]|\\.)*"|[^,]+)\s*/) k, v = c[1], c[2] if v =~ /^"(.*)"$/ v = $1 diff --git a/test/net/imap/test_imap_authenticators.rb b/test/net/imap/test_imap_authenticators.rb index 6bb111c0..3ef15ab7 100644 --- a/test/net/imap/test_imap_authenticators.rb +++ b/test/net/imap/test_imap_authenticators.rb @@ -167,4 +167,14 @@ def test_digest_md5_authenticator_no_qop auth.process('Qop=""') end end + + def test_digest_md5_authenticator_illinear + pre = ->(n) {'qop="a' + ',x'*n} + assert_linear_performance([5, 10, 15, 20], pre: pre) do |challenge| + auth = digest_md5("user", "pass") + assert_raise(Net::IMAP::DataFormatError) do + auth.process(challenge) + end + end + end end