app/controllers/projects/git_http_client_controller.rb
def project_id_with_suffix
    id = params[:project_id] || ''

    %w[.wiki.git .git].each do |suffix|
      if id.end_with?(suffix)
        # Be careful to only remove the suffix from the end of 'id'.
        # Accidentally removing it from the middle is how security
        # vulnerabilities happen!
        return [id.slice(0, id.length - suffix.length), suffix]
      end
    end

    # Something is wrong with params[:project_id]; do not pass it on.
    [nil, nil]
  end
# This method returns two values so that we can parse
# params[:project_id] (untrusted input!) in exactly one place.
This method returns two values so that we can parse
params[:project_id] (untrusted input!) in exactly one place.
This method returns two values so that we can parse params [ : project_id ] ( untrusted input! ) in exactly one place .
def project_id_with_suffix
    id = params[:project_id] || ''
    %w[.wiki.git .git].each do |suffix|
      if id.end_with?(suffix)
        return [id.slice(0, id.length - suffix.length), suffix]
      end
    end
    [nil, nil]
  end
def project_id_with_suffix id = params [ :project_id ] || '' %w[ .wiki.git .git ] . each do | suffix | if id . end_with? ( suffix ) return [ id . slice ( 0 , id . length - suffix . length ) , suffix ] end end [ nil , nil ] end
This method returns two values so that we can parse
params[:project_id] (untrusted input!)
This method returns two values so that we can parse params [ : project_id ] ( untrusted input! )
# Be careful to only remove the suffix from the end of 'id'. # Accidentally removing it from the middle is how security # vulnerabilities happen! # Something is wrong with params[:project_id]; do not pass it on.