Bug #6765
closedcreating a medium with single whitespace(" ") shouldn't be allowed
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1121972
Description of problem:
I was trying to create media with single white space in quotes (" ") and it was created successfully. However when I increase the the whitespace, UI throws error:
can't be blank or contain trailing white spaces.
so UI should throw same error while creating media with single whitespace.
Version-Release number of selected component (if applicable):
sat6 GA snap1
How reproducible:
always
Steps to Reproduce:
1. create a media with single while space in quotes in name
2.
3.
Actual results:
media created successfully
Expected results:
UI should throw error:
can't be blank or contain trailing white spaces.
Additional info:
logs from production.log
Processing by MediaController#create as /*
Parameters: {"utf8"=>"✓", "search"=>"", "authenticity_token"=>"VX+UKFuIgqWyHwxAdhnLIrzFLAmDgGh5qENjFuLnsso=", "medium"=>{"name"=>"\" \"", "path"=>"http://mirror.fakeos.org/G8/$major.$minor/os/$arch", "media_path"=>"", "config_path"=>"", "image_path"=>"", "os_family"=>"", "location_ids"=>[""], "organization_ids"=>[""]}}
Redirected to https://dhcp201-195.englab.pnq.redhat.com/media
Completed 302 Found in 29ms (ActiveRecord: 10.3ms)
Processing by MediaController#index as */
Rendered media/index.html.erb within layouts/application (91.4ms)
Rendered common/_searchbar.html.erb (3.5ms)
Rendered home/_user_dropdown.html.erb (1.5ms)
Read fragment views/tabs_and_title_records-3 (0.1ms)
Rendered home/_topbar.html.erb (2.4ms)
Rendered layouts/base.html.erb (3.9ms)
Completed 200 OK in 112ms (Views: 99.6ms | ActiveRecord: 2.1ms)
Added by Tomer Brisker over 10 years ago
Added by Tomer Brisker over 10 years ago
Fixes #6765 - correct wrong validation on media name
Regex used for validation was wrong, raising error on multiple white spaces instead of on trailing white space.
Trailing white space is stripped anyways by StripWhitespace concern before validation.
Original bug was concerning " " passing validation. However, that is not a single white space but rather quotes with a
space between them; while not useful, it is a valid name. (The quotes are escaped in the db)
(cherry picked from commit d3d17516a5b2b92c357a756fef2f18599f919a76)
Fixes #6765 - correct wrong validation on media name
Regex used for validation was wrong, raising error on multiple white spaces instead of on trailing white space.
Trailing white space is stripped anyways by StripWhitespace concern before validation.
Original bug was concerning " " passing validation. However, that is not a single white space but rather quotes with a
space between them; while not useful, it is a valid name. (The quotes are escaped in the db)