From c115a84c8b73363b281709a779a0fefbf7e46b13 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Thu, 18 Dec 2014 00:51:05 -0800 Subject: 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 --- .../active_record/connection_adapters/postgresql/oid/uuid.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') 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 -- cgit v1.2.3