Skip to content

Commit

Permalink
Remove nested quantifier
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and nevans committed Jul 26, 2023
1 parent 2a85ac1 commit c92ed92
Show file tree
Hide file tree
Showing 2 changed files with 11 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 @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/net/imap/test_imap_authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c92ed92

Please sign in to comment.