From f9d2de040aff586a41f0d40e3f45e679c6d3a9f0 Mon Sep 17 00:00:00 2001 From: cichol Date: Wed, 6 May 2020 12:22:24 -0300 Subject: [PATCH] #finger should correctly handle %40 in acct uri --- lib/goldfinger/client.rb | 2 +- spec/goldfinger/client_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/goldfinger/client.rb b/lib/goldfinger/client.rb index e359d2b..0a4d3e4 100644 --- a/lib/goldfinger/client.rb +++ b/lib/goldfinger/client.rb @@ -43,7 +43,7 @@ def url end def standard_url - "#{@scheme}://#{domain}/.well-known/webfinger?resource=#{@uri}" + "#{@scheme}://#{domain}/.well-known/webfinger?resource=#{CGI.escape @uri}" end def url_from_template(template) diff --git a/spec/goldfinger/client_spec.rb b/spec/goldfinger/client_spec.rb index 95a079f..9b6f995 100644 --- a/spec/goldfinger/client_spec.rb +++ b/spec/goldfinger/client_spec.rb @@ -49,4 +49,17 @@ end end end + + describe '#finger' do + before do + stub_request(:get, 'https://ab.com/.well-known/webfinger?resource=acct:someone%40gmail.com@ab.com').to_return(status: 404) + stub_request(:get, 'https://ab.com/.well-known/webfinger?resource=acct:someone%2540gmail.com@ab.com').to_return(body: fixture('quitter.no_.well-known_webfinger.json'), headers: { content_type: 'application/jrd+json' }) + end + + subject { Goldfinger::Client.new('acct:someone%40gmail.com@ab.com') } + + it 'should correctly handle %40 in acct uri' do + expect(subject.finger).to be_instance_of Goldfinger::Result + end + end end