Skip to content
Permalink
Browse files

fix RestGraph#parse_fbs! for fbs which has json inside (thus " char)

  • Loading branch information...
godfat committed Jun 1, 2011
1 parent 5908a1c commit 786fd7c5848c07736d8f6819c09769cb235f871a
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/rest-graph/core.rb
  2. +9 −0 test/test_parse.rb
@@ -350,7 +350,7 @@ def parse_cookies! cookies
def parse_fbs! fbs
self.data = check_sig_and_return_data(
# take out facebook sometimes there but sometimes not quotes in cookies
Rack::Utils.parse_query(fbs.to_s.gsub('"', '')))
Rack::Utils.parse_query(fbs.to_s.sub(/^"/, '').sub(/"$/, '')))
end

def parse_json! json
@@ -13,6 +13,15 @@
rg.data .should == {}
end

should 'parse if fbs contains json as well' do
algorithm = 'HMAC-SHA256'
user = '{"country"=>"us", "age"=>{"min"=>21}}'
data = {'algorithm' => algorithm, 'user' => user}
rg = RestGraph.new(:data => data, :secret => 'secret')
sig = rg.send(:calculate_sig, data)
rg.parse_fbs!("\"#{rg.fbs}\"").should == data.merge('sig' => sig)
end

should 'extract correct access_token or fail checking sig' do
access_token = '1|2-5|f.'
app_id = '1829'

0 comments on commit 786fd7c

Please sign in to comment.
You can’t perform that action at this time.