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'