]> source.dussan.org Git - redmine.git/commitdiff
Use \A and \z in validation regexps.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Dec 2012 10:59:31 +0000 (10:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Dec 2012 10:59:31 +0000 (10:59 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10960 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
app/models/repository.rb
app/models/repository/subversion.rb
app/models/user.rb
app/models/version.rb
app/models/wiki.rb

index 742059965ea8c83b7351fa799c3a3fbff76717f7..de708cc1a7ed9e46d7bc94b1e46b23905a5d4541 100644 (file)
@@ -77,7 +77,7 @@ class Project < ActiveRecord::Base
   validates_length_of :homepage, :maximum => 255
   validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH
   # donwcase letters, digits, dashes but not digits only
-  validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :if => Proc.new { |p| p.identifier_changed? }
+  validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :if => Proc.new { |p| p.identifier_changed? }
   # reserved words
   validates_exclusion_of :identifier, :in => %w( new )
 
index a8e967d0d16e28068c5bf65d43eea7b6921adea7..437b494d05503a701564911e2963329788c6be66 100644 (file)
@@ -42,7 +42,7 @@ class Repository < ActiveRecord::Base
   validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
   validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
   # donwcase letters, digits, dashes, underscores but not digits only
-  validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :allow_blank => true
+  validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
   # Checks if the SCM is enabled when creating a repository
   validate :repo_create_validation, :on => :create
 
index c50e99ec8589294a06cdad04bb5abcf7993dfa0f..9da9e543c5148d5ce30c4414542c26142194ee0f 100644 (file)
@@ -20,7 +20,7 @@ require 'redmine/scm/adapters/subversion_adapter'
 class Repository::Subversion < Repository
   attr_protected :root_url
   validates_presence_of :url
-  validates_format_of :url, :with => /^(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
+  validates_format_of :url, :with => /\A(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
 
   def self.scm_adapter_class
     Redmine::Scm::Adapters::SubversionAdapter
index 0c7fd7558d30f11c741da170bac80802370fc502..1f2acb2a74d9705360b96684ff3d2735b673e3ec 100644 (file)
@@ -93,10 +93,10 @@ class User < Principal
   validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false
   validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false
   # Login must contain lettres, numbers, underscores only
-  validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
+  validates_format_of :login, :with => /\A[a-z0-9_\-@\.]*\z/i
   validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT
   validates_length_of :firstname, :lastname, :maximum => 30
-  validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
+  validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true
   validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true
   validates_confirmation_of :password, :allow_nil => true
   validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
index 07d312ab957b72435e72155086351d62a564b361..f96ccb012819fa368794d65dcc08257dc9dcb3b2 100644 (file)
@@ -30,7 +30,7 @@ class Version < ActiveRecord::Base
   validates_presence_of :name
   validates_uniqueness_of :name, :scope => [:project_id]
   validates_length_of :name, :maximum => 60
-  validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
+  validates_format_of :effective_date, :with => /\A\d{4}-\d{2}-\d{2}\z/, :message => :not_a_date, :allow_nil => true
   validates_inclusion_of :status, :in => VERSION_STATUSES
   validates_inclusion_of :sharing, :in => VERSION_SHARINGS
   validate :validate_version
index 983bb94f681da5aadea9969d0ba4faaec54dfa5a..078b2a04b0fa53ca43f8a74fe33e76b7be69ee1f 100644 (file)
@@ -24,7 +24,7 @@ class Wiki < ActiveRecord::Base
   acts_as_watchable
 
   validates_presence_of :start_page
-  validates_format_of :start_page, :with => /^[^,\.\/\?\;\|\:]*$/
+  validates_format_of :start_page, :with => /\A[^,\.\/\?\;\|\:]*\z/
 
   safe_attributes 'start_page'