Skip to content

Commit

Permalink
Fix namespace expectations in Salmon parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Oct 16, 2016
1 parent af832ac commit 18f8af2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/ostatus2/salmon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def digest
def parse(raw_body)
xml = Nokogiri::XML(raw_body)

raise OStatus2::BadSalmonError if xml.at_xpath('//me:data').nil? || xml.at_xpath('//me:data').attribute('type').nil? || xml.at_xpath('//me:sig').nil? || xml.at_xpath('//me:encoding').nil? || xml.at_xpath('//me:alg').nil?
raise OStatus2::BadSalmonError if xml.at_xpath('//me:data', me: XMLNS).nil? || xml.at_xpath('//me:data', me: XMLNS).attribute('type').nil? || xml.at_xpath('//me:sig', me: XMLNS).nil? || xml.at_xpath('//me:encoding', me: XMLNS).nil? || xml.at_xpath('//me:alg', me: XMLNS).nil?

data = xml.at_xpath('//me:data')
data = xml.at_xpath('//me:data', me: XMLNS)
type = data.attribute('type').value
body = decode_base64(data.content)
sig = xml.at_xpath('//me:sig')
sig = xml.at_xpath('//me:sig', me: XMLNS)
signature = decode_base64(sig.content)
encoding = xml.at_xpath('//me:encoding').content
alg = xml.at_xpath('//me:alg').content
encoding = xml.at_xpath('//me:encoding', me: XMLNS).content
alg = xml.at_xpath('//me:alg', me: XMLNS).content
plaintext = plaintext_signature(body, type, encoding, alg)

[body, plaintext, signature]
Expand Down
2 changes: 1 addition & 1 deletion lib/ostatus2/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module OStatus2
VERSION = "1.0.1"
VERSION = "1.0.2"
end

0 comments on commit 18f8af2

Please sign in to comment.