Skip to content

Commit

Permalink
Replace deprecated URI.escape
Browse files Browse the repository at this point in the history
URI deprecated the escape method on updating to Ruby 3.0.0.
See ruby/uri#14
  • Loading branch information
danidoni authored and hennevogel committed Mar 11, 2022
1 parent eb7f5d1 commit 0a6a30a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/api/app/helpers/maintenance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def release_package_relink(link, action, target_package_name, target_project, tp
link.remove_attribute('project') # its a local link, project name not needed
link['package'] = link['package'].gsub(/\..*/, '') + target_package_name.gsub(/.*\./, '.') # adapt link target with suffix
link_xml = link.to_xml
Backend::Connection.put "/source/#{URI.escape(target_project.name)}/#{URI.escape(target_package_name)}/_link?rev=repository&user=#{CGI.escape(User.session!.login)}", link_xml
Backend::Connection.put "/source/#{CGI.escape(target_project.name)}/#{CGI.escape(target_package_name)}/_link?rev=repository&user=#{CGI.escape(User.session!.login)}", link_xml

md5 = Digest::MD5.hexdigest(link_xml)
# commit with noservice parameter
Expand All @@ -108,7 +108,7 @@ def release_package_relink(link, action, target_package_name, target_project, tp
comment: "Set local link to #{target_package_name} via maintenance_release request"
}
upload_params[:requestid] = action.bs_request.number if action
upload_path = "/source/#{URI.escape(target_project.name)}/#{URI.escape(target_package_name)}"
upload_path = "/source/#{CGI.escape(target_project.name)}/#{CGI.escape(target_package_name)}"
upload_path << Backend::Connection.build_query_from_hash(upload_params, [:user, :comment, :cmd, :noservice, :requestid])
answer = Backend::Connection.post upload_path, "<directory> <entry name=\"_link\" md5=\"#{md5}\" /> </directory>"
tpkg.sources_changed(dir_xml: answer)
Expand All @@ -131,7 +131,7 @@ def release_package_create_main_package(request, source_package, target_package_
rev: 'repository',
comment: "Set link to #{target_package_name} via maintenance_release request"
}
upload_path = "/source/#{URI.escape(target_project.name)}/#{URI.escape(base_package_name)}/_link"
upload_path = "/source/#{CGI.escape(target_project.name)}/#{CGI.escape(base_package_name)}/_link"
upload_path << Backend::Connection.build_query_from_hash(upload_params, [:user, :rev])
link = "<link package='#{target_package_name}' cicount='copy' />\n"
md5 = Digest::MD5.hexdigest(link)
Expand All @@ -140,7 +140,7 @@ def release_package_create_main_package(request, source_package, target_package_
upload_params[:cmd] = 'commitfilelist'
upload_params[:noservice] = '1'
upload_params[:requestid] = request.number if request
upload_path = "/source/#{URI.escape(target_project.name)}/#{URI.escape(base_package_name)}"
upload_path = "/source/#{CGI.escape(target_project.name)}/#{CGI.escape(base_package_name)}"
upload_path << Backend::Connection.build_query_from_hash(upload_params, [:user, :comment, :cmd, :noservice, :requestid])
answer = Backend::Connection.post upload_path, "<directory> <entry name=\"_link\" md5=\"#{md5}\" /> </directory>"
lpkg.sources_changed(dir_xml: answer)
Expand Down Expand Up @@ -232,7 +232,7 @@ def copy_single_binary(arch, target_repository, source_project_name, source_pack
cp_params[:setupdateinfoid] = update_info_id if update_info_id
cp_params[:setrelease] = setrelease if setrelease
cp_params[:multibuild] = '1' unless source_package_name.include?(':')
cp_path = "/build/#{CGI.escape(target_repository.project.name)}/#{URI.escape(target_repository.name)}/#{URI.escape(arch.name)}/#{URI.escape(target_package_name)}"
cp_path = "/build/#{CGI.escape(target_repository.project.name)}/#{CGI.escape(target_repository.name)}/#{CGI.escape(arch.name)}/#{CGI.escape(target_package_name)}"

cp_path << Backend::Connection.build_query_from_hash(cp_params, [:cmd, :oproject, :opackage,
:orepository, :setupdateinfoid,
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def bugzilla_url(email_list = '', desc = '')
cc = ('&cc=' + email_list[1..-1].join('&cc=')) if email_list
end

URI.escape(
CGI.escape(
"#{@configuration['bugzilla_url']}/enter_bug.cgi?classification=7340&product=openSUSE.org" \
"&component=3rd party software&assigned_to=#{assignee}#{cc}&short_desc=#{desc}"
)
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ def sources_changed(opts = {})
end

def self.source_path(project, package, file = nil, opts = {})
path = "/source/#{URI.escape(project)}/#{URI.escape(package)}"
path += "/#{URI.escape(file)}" if file.present?
path = "/source/#{CGI.escape(project)}/#{CGI.escape(package)}"
path += "/#{CGI.escape(file)}" if file.present?
path += '?' + opts.to_query if opts.present?
path
end
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def backend_build_command(command, build_project, params)
permitted_params = params.permit(:repository, :arch, :package, :code, :wipe)

# do not use project.name because we missuse the package source container for build container operations
Backend::Connection.post("/build/#{URI.escape(build_project)}?cmd=#{command}&#{permitted_params.to_h.to_query}")
Backend::Connection.post("/build/#{CGI.escape(build_project)}?cmd=#{command}&#{permitted_params.to_h.to_query}")
rescue Backend::Error, Timeout::Error, Project::WritePermissionError => e
errors.add(:base, e.message)
return false
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ def parent_projects(project_name)
end

def source_path(project, file = nil, opts = {})
path = "/source/#{URI.escape(project)}"
path += "/#{URI.escape(file)}" if file.present?
path = "/source/#{CGI.escape(project)}"
path += "/#{CGI.escape(file)}" if file.present?
path += '?' + opts.to_query if opts.present?
path
end
Expand Down
8 changes: 4 additions & 4 deletions src/api/spec/factories/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@
after(:create) do |package|
# NOTE: Enable global write through when writing new VCR cassetes.
# ensure the backend knows the project
Backend::Connection.put("/source/#{URI.escape(package.project.name)}/#{URI.escape(package.name)}/_service", '<services/>') if CONFIG['global_write_through']
Backend::Connection.put("/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/_service", '<services/>') if CONFIG['global_write_through']
end
end

factory :package_with_broken_service do
after(:create) do |package|
# NOTE: Enable global write through when writing new VCR cassetes.
# ensure the backend knows the project
Backend::Connection.put("/source/#{URI.escape(package.project.name)}/#{URI.escape(package.name)}/_service", '<service>broken</service>') if CONFIG['global_write_through']
Backend::Connection.put("/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/_service", '<service>broken</service>') if CONFIG['global_write_through']
end
end

Expand All @@ -131,7 +131,7 @@
# ensure the backend knows the project
if CONFIG['global_write_through']
full_path = "/source/#{package.project.name}/#{package.name}/#{evaluator.changes_file_name}"
Backend::Connection.put(URI.escape(full_path), evaluator.changes_file_content)
Backend::Connection.put(CGI.escape(full_path), evaluator.changes_file_content)
end
end
end
Expand Down Expand Up @@ -160,7 +160,7 @@
# ensure the backend knows the project
if CONFIG['global_write_through']
full_path = "/source/#{package.project.name}/#{package.name}/#{evaluator.kiwi_file_name}"
Backend::Connection.put(URI.escape(full_path), evaluator.kiwi_file_content)
Backend::Connection.put(CGI.escape(full_path), evaluator.kiwi_file_content)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/models/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@
before do
if CONFIG['global_write_through']
full_path = "/source/#{package.project.name}/#{package.name}/lorem.changes"
Backend::Connection.put(URI.escape(full_path), 'Lorem ipsum dolorem')
Backend::Connection.put(CGI.escape(full_path), 'Lorem ipsum dolorem')
end
end

Expand Down

0 comments on commit 0a6a30a

Please sign in to comment.