summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-08 10:59:31 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-08 10:59:31 +0000
commit147e7a8d61722e99e31cf881b3fc0b8e9c4e6a11 (patch)
tree27fa67f1a9684246ed489717195c84ba2f4e6c7b
parent4c6dfdf95fcb1ae4b014ea595d1f6d5bad64eb48 (diff)
downloadredmine-147e7a8d61722e99e31cf881b3fc0b8e9c4e6a11.tar.gz
redmine-147e7a8d61722e99e31cf881b3fc0b8e9c4e6a11.zip
Use \A and \z in validation regexps.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10960 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/models/repository/subversion.rb2
-rw-r--r--app/models/user.rb4
-rw-r--r--app/models/version.rb2
-rw-r--r--app/models/wiki.rb2
6 files changed, 7 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 742059965..de708cc1a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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 )
diff --git a/app/models/repository.rb b/app/models/repository.rb
index a8e967d0d..437b494d0 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -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
diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb
index c50e99ec8..9da9e543c 100644
--- a/app/models/repository/subversion.rb
+++ b/app/models/repository/subversion.rb
@@ -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
diff --git a/app/models/user.rb b/app/models/user.rb
index 0c7fd7558..1f2acb2a7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
diff --git a/app/models/version.rb b/app/models/version.rb
index 07d312ab9..f96ccb012 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -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
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index 983bb94f6..078b2a04b 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -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'