Project

General

Profile

« Previous | Next » 

Revision 21f2b8d4

Added by Ivan Necas almost 11 years ago

  • ID 21f2b8d4197a15ac8ace3a9c87e0fbcb1e2c49dc

fixes #2685 incorrect and inefficient regexp checking medium name format

It takes eternity to compute something like this:

"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa b" =~ /\A(\S+\s?)+\Z

Also "this is wrong " was not matched
(cherry picked from commit cd2892774b6f6073bb189bd17ea7fcaec76388e6)

View differences:

app/models/medium.rb
validates_uniqueness_of :name
validates_uniqueness_of :path
validates_presence_of :name, :path
validates_format_of :name, :with => /\A(\S+\s?)+\Z/, :message => N_("can't be blank or contain trailing white spaces.")
validates_format_of :name, :with => /\A(\S+\s)*\S+\Z/, :message => N_("can't be blank or contain trailing white spaces.")
validates_format_of :path, :with => /^(http|https|ftp|nfs):\/\//,
:message => _("Only URLs with schema http://, https://, ftp:// or nfs:// are allowed (e.g. nfs://server/vol/dir)")

Also available in: Unified diff