diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-31 16:42:25 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-31 16:42:25 +0000 |
commit | 256d3871597079a274aa9685b66e34307ff479b1 (patch) | |
tree | 689fd03013204152139d63a4a86b2c28e1e2d5dd /activerecord | |
parent | 43f5ab93e016ced1592046229b82c28b2dae4556 (diff) | |
download | rails-256d3871597079a274aa9685b66e34307ff479b1.tar.gz rails-256d3871597079a274aa9685b66e34307ff479b1.tar.bz2 rails-256d3871597079a274aa9685b66e34307ff479b1.zip |
Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@288 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/validations_test.rb | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 1499013477..455748b98c 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin] + * Fixed broken transactions that were actually only running object-level and not db level transactions [andreas] * Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 1d0dd68df8..a451e4299a 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -240,7 +240,7 @@ module ActiveRecord raise(ArgumentError, "A regular expression must be supplied as the :with option of the configuration hash") unless configuration[:with].is_a?(Regexp) for attr_name in attr_names - class_eval(%(#{validation_method(configuration[:on])} %{errors.add("#{attr_name}", "#{configuration[:message]}") unless #{attr_name} and #{attr_name}.to_s.match(/#{configuration[:with]}/)})) + class_eval(%(#{validation_method(configuration[:on])} %{errors.add("#{attr_name}", "#{configuration[:message]}") unless #{attr_name} and #{attr_name}.to_s.match(/#{Regexp.quote(configuration[:with].source)}/)})) end end diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index db6aab653b..ed9d76bd3e 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -224,7 +224,7 @@ class ValidationsTest < Test::Unit::TestCase end def test_validate_format - Topic.validates_format_of(:title, :content, :with => /^Validation macros rule!$/, :message => "is bad data") + Topic.validates_format_of(:title, :content, :with => /^Validation\smacros \w+!$/, :message => "is bad data") t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!") assert !t.valid?, "Shouldn't be valid" |