Skip to content

Commit

Permalink
[ci][webui] Prevent package submit requests failures because of trail…
Browse files Browse the repository at this point in the history
…ing whitespaces

Sanitize project name in submit_request action, similar to package name sanitation in cee3d3e
  • Loading branch information
bgeuken committed Nov 23, 2015
1 parent 814c71d commit 471f5b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -248,6 +248,7 @@ def submit_request_dialog
def submit_request
required_parameters :project, :package

target_project_name = params[:targetproject].strip
package_name = params[:package].strip
project_name = params[:project].strip

Expand All @@ -257,7 +258,7 @@ def submit_request
target_package_name = params[:targetpackage].try(:strip)
end

if params[:targetproject].blank?
if target_project_name.blank?
flash[:error] = 'Please provide a target for the submit request'
redirect_to action: :show, project: project_name, package: package_name
return
Expand All @@ -271,7 +272,7 @@ def submit_request

opts = { source_project: project_name,
source_package: package_name,
target_project: params[:targetproject],
target_project: target_project_name,
target_package: target_package_name }
if params[:sourceupdate]
opts[:sourceupdate] = params[:sourceupdate]
Expand Down Expand Up @@ -326,7 +327,7 @@ def submit_request
supersede_notice += supersede_errors.join('. ')
end
flash[:notice] = "Created <a href='#{request_show_path(req.id)}'>submit request #{req.id}</a>\
to <a href='#{project_show_path(params[:targetproject])}'>#{params[:targetproject]}</a>
to <a href='#{project_show_path(target_project_name)}'>#{target_project_name}</a>
#{supersede_notice}"
redirect_to(action: 'show', project: project_name, package: package_name)
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/functional/webui/package_controller_test.rb
Expand Up @@ -392,7 +392,7 @@ def test_submit_request

click_link("Submit package")
# Note: The whitespaces are part of the test, see issue#1248 for details
fill_in "To target project", with: "home:Iggy"
fill_in "To target project", with: " home:Iggy "
fill_in "To target package", with: " ToBeDeletedTestPack "
click_button("Ok")
page.must_have_text "Created submit request #{BsRequest.last.id} to home:Iggy"
Expand Down

0 comments on commit 471f5b9

Please sign in to comment.