aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/module/attribute_accessor_test.rb
diff options
context:
space:
mode:
authorAliaksandr Buhayeu <aliaksandr.buhayeu@gmail.com>2015-06-17 14:58:36 +0300
committerAliaksandr Buhayeu <aliaksandr.buhayeu@gmail.com>2015-10-01 21:27:58 +0300
commit3005c25a36bcf30e08940a6cd0414752b35ba971 (patch)
tree702e6dc3bade409740989a49dde4ced2677ffbd9 /activesupport/test/core_ext/module/attribute_accessor_test.rb
parentf78650d56e75ee266a17e12cd97a136d10484a67 (diff)
downloadrails-3005c25a36bcf30e08940a6cd0414752b35ba971.tar.gz
rails-3005c25a36bcf30e08940a6cd0414752b35ba971.tar.bz2
rails-3005c25a36bcf30e08940a6cd0414752b35ba971.zip
Regex fix for mattr_accessor validation
Change ^ and $ operators to \A and \z to prevent code injection after the line breaks
Diffstat (limited to 'activesupport/test/core_ext/module/attribute_accessor_test.rb')
-rw-r--r--activesupport/test/core_ext/module/attribute_accessor_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module/attribute_accessor_test.rb b/activesupport/test/core_ext/module/attribute_accessor_test.rb
index 128c5e3d1a..0b0f3a2808 100644
--- a/activesupport/test/core_ext/module/attribute_accessor_test.rb
+++ b/activesupport/test/core_ext/module/attribute_accessor_test.rb
@@ -69,6 +69,20 @@ class ModuleAttributeAccessorTest < ActiveSupport::TestCase
end
end
assert_equal "invalid attribute name: 1nvalid", exception.message
+
+ exception = assert_raises NameError do
+ Class.new do
+ mattr_reader "valid_part\ninvalid_part"
+ end
+ end
+ assert_equal "invalid attribute name: valid_part\ninvalid_part", exception.message
+
+ exception = assert_raises NameError do
+ Class.new do
+ mattr_writer "valid_part\ninvalid_part"
+ end
+ end
+ assert_equal "invalid attribute name: valid_part\ninvalid_part", exception.message
end
def test_should_use_default_value_if_block_passed