aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-12-18 00:51:05 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2014-12-18 00:51:05 -0800
commitc115a84c8b73363b281709a779a0fefbf7e46b13 (patch)
tree8a6ce53233da297b2cf4e177ac4d4ef2ae291602 /activerecord/test
parent63f2bba6bb0de1584891cb8a9206b5c8b82fec49 (diff)
downloadrails-c115a84c8b73363b281709a779a0fefbf7e46b13.tar.gz
rails-c115a84c8b73363b281709a779a0fefbf7e46b13.tar.bz2
rails-c115a84c8b73363b281709a779a0fefbf7e46b13.zip
Relax the UUID regex
Apparently PG does not validate against RFC 4122. The intent of the original patch is just to protect against PG errors (which potentially breaks txns, etc) because of bad user input, so we shouldn't try any harder than PG itself. Closes #17931
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/adapters/postgresql/uuid_test.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
index fac21996ed..7b7532993c 100644
--- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
@@ -69,13 +69,18 @@ class PostgresqlUUIDTest < ActiveRecord::TestCase
assert_equal 'foobar', uuid.guid_before_type_cast
end
- def test_rfc_4122_regex
+ def test_acceptable_uuid_regex
# Valid uuids
['A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11',
'{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}',
'a0eebc999c0b4ef8bb6d6bb9bd380a11',
'a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11',
- '{a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11}'].each do |valid_uuid|
+ '{a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11}',
+ # The following is not a valid RFC 4122 UUID, but PG doesn't seem to care,
+ # so we shouldn't block it either. (Pay attention to "fb6d" – the "f" here
+ # is invalid – it must be one of 8, 9, A, B, a, b according to the spec.)
+ '{a0eebc99-9c0b-4ef8-fb6d-6bb9bd380a11}',
+ ].each do |valid_uuid|
uuid = UUIDType.new guid: valid_uuid
assert_not_nil uuid.guid
end
@@ -87,7 +92,6 @@ class PostgresqlUUIDTest < ActiveRecord::TestCase
0.0,
true,
'Z0000C99-9C0B-4EF8-BB6D-6BB9BD380A11',
- '{a0eebc99-9c0b-4ef8-fb6d-6bb9bd380a11}',
'a0eebc999r0b4ef8ab6d6bb9bd380a11',
'a0ee-bc99------4ef8-bb6d-6bb9-bd38-0a11',
'{a0eebc99-bb6d6bb9-bd380a11}'].each do |invalid_uuid|