diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-12-18 00:51:05 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-12-18 00:51:05 -0800 |
commit | c115a84c8b73363b281709a779a0fefbf7e46b13 (patch) | |
tree | 8a6ce53233da297b2cf4e177ac4d4ef2ae291602 /activerecord/lib/active_record/connection_adapters | |
parent | 63f2bba6bb0de1584891cb8a9206b5c8b82fec49 (diff) | |
download | rails-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/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb index 033e0324bb..97b4fd3d08 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb @@ -3,14 +3,7 @@ module ActiveRecord module PostgreSQL module OID # :nodoc: class Uuid < Type::Value # :nodoc: - RFC_4122 = %r{\A\{?[a-fA-F0-9]{4}-? - [a-fA-F0-9]{4}-? - [a-fA-F0-9]{4}-? - [1-5][a-fA-F0-9]{3}-? - [8-Bab][a-fA-F0-9]{3}-? - [a-fA-F0-9]{4}-? - [a-fA-F0-9]{4}-? - [a-fA-F0-9]{4}-?\}?\z}x + ACCEPTABLE_UUID = %r{\A\{?([a-fA-F0-9]{4}-?){8}\}?\z}x alias_method :type_cast_for_database, :type_cast_from_database @@ -19,7 +12,7 @@ module ActiveRecord end def type_cast(value) - value.to_s[RFC_4122, 0] + value.to_s[ACCEPTABLE_UUID, 0] end end end |