Project

General

Profile

Bug #6765

creating a medium with single whitespace(" ") shouldn't be allowed

Added by Dominic Cleal almost 5 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

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)


Related issues

Related to Foreman - Bug #5923: ptable validation trailing spaces incorrectly allows one spaceClosed2014-05-25
Related to Foreman - Refactor #8414: Extract repeating validators from modelsClosed2014-11-16

Associated revisions

Revision d3d17516 (diff)
Added by Tomer Brisker over 4 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)

Revision 5c843701 (diff)
Added by Tomer Brisker over 4 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)

History

#1 Updated by Dominic Cleal almost 5 years ago

  • Category set to Rails

We seem to have many variations of name validators, it's probably time to just create a custom validator which is covered well by unit tests, and apply it consistently across the application.

#2 Updated by Dominic Cleal almost 5 years ago

  • Related to Bug #5923: ptable validation trailing spaces incorrectly allows one space added

#3 Updated by Tomer Brisker over 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Tomer Brisker

#4 Updated by The Foreman Bot over 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/1941 added
  • Pull request deleted ()

#5 Updated by Tomer Brisker over 4 years ago

  • Related to Refactor #8414: Extract repeating validators from models added

#6 Updated by Anonymous over 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#7 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 29

Also available in: Atom PDF