Remove double-query for signed query strings (#34610)
This commit is contained in:
		@@ -6,14 +6,13 @@
 | 
			
		||||
class HttpSignatureDraft
 | 
			
		||||
  REQUEST_TARGET = '(request-target)'
 | 
			
		||||
 | 
			
		||||
  def initialize(keypair, key_id, full_path: true)
 | 
			
		||||
  def initialize(keypair, key_id)
 | 
			
		||||
    @keypair = keypair
 | 
			
		||||
    @key_id = key_id
 | 
			
		||||
    @full_path = full_path
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def request_target(verb, url)
 | 
			
		||||
    if url.query.nil? || !@full_path
 | 
			
		||||
    if url.query.nil?
 | 
			
		||||
      "#{verb} #{url.path}"
 | 
			
		||||
    else
 | 
			
		||||
      "#{verb} #{url.path}?#{url.query}"
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,6 @@ class Request
 | 
			
		||||
    @url         = Addressable::URI.parse(url).normalize
 | 
			
		||||
    @http_client = options.delete(:http_client)
 | 
			
		||||
    @allow_local = options.delete(:allow_local)
 | 
			
		||||
    @full_path   = !options.delete(:omit_query_string)
 | 
			
		||||
    @options     = {
 | 
			
		||||
      follow: {
 | 
			
		||||
        max_hops: 3,
 | 
			
		||||
@@ -102,7 +101,7 @@ class Request
 | 
			
		||||
 | 
			
		||||
    key_id = ActivityPub::TagManager.instance.key_uri_for(actor)
 | 
			
		||||
    keypair = sign_with.present? ? OpenSSL::PKey::RSA.new(sign_with) : actor.keypair
 | 
			
		||||
    @signing = HttpSignatureDraft.new(keypair, key_id, full_path: @full_path)
 | 
			
		||||
    @signing = HttpSignatureDraft.new(keypair, key_id)
 | 
			
		||||
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user