Skip to content

Commit

Permalink
Merge pull request jnunemaker#338 from orgsync/fix-qop-parsing
Browse files Browse the repository at this point in the history
quotes qop value prior to parsing
  • Loading branch information
greatuserongithub committed Oct 24, 2014
2 parents fea7a18 + c187bb6 commit a028de4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/httparty/net_digest_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def authorization_header
private

def parse(response_header)
response_header['www-authenticate'] =~ /Digest (.*)/
header = response_header['www-authenticate']
.gsub(/qop=(auth(?:-int)?)/, %Q(qop="\\1"))

header =~ /Digest (.*)/
params = {}
$1.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
params
Expand Down
11 changes: 11 additions & 0 deletions spec/httparty/net_digest_auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ def authorization_header
end
end

context "when quality of protection (qop) is unquoted" do
before do
@digest = setup_digest({
'www-authenticate' => 'Digest realm="[email protected]", nonce="NONCE", qop=auth',
})
end

it "should still set qop" do
authorization_header.should include(%Q(qop="auth"))
end
end

context "with unspecified quality of protection (qop)" do
before do
Expand Down

0 comments on commit a028de4

Please sign in to comment.