1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #29715 from reverbdotcom/ptd/fix-invalid-uuids

Don't allow uuids with orphan curly braces
This commit is contained in:
Matthew Draper 2017-07-09 07:59:44 +09:30 committed by GitHub
commit 650ea5e5cf
2 changed files with 4 additions and 2 deletions

View file

@ -3,7 +3,7 @@ module ActiveRecord
module PostgreSQL module PostgreSQL
module OID # :nodoc: module OID # :nodoc:
class Uuid < Type::Value # :nodoc: class Uuid < Type::Value # :nodoc:
ACCEPTABLE_UUID = %r{\A\{?([a-fA-F0-9]{4}-?){8}\}?\z}x ACCEPTABLE_UUID = %r{\A(\{)?([a-fA-F0-9]{4}-?){8}(?(1)\}|)\z}
alias_method :serialize, :deserialize alias_method :serialize, :deserialize

View file

@ -124,7 +124,9 @@ class PostgresqlUUIDTest < ActiveRecord::PostgreSQLTestCase
"Z0000C99-9C0B-4EF8-BB6D-6BB9BD380A11", "Z0000C99-9C0B-4EF8-BB6D-6BB9BD380A11",
"a0eebc999r0b4ef8ab6d6bb9bd380a11", "a0eebc999r0b4ef8ab6d6bb9bd380a11",
"a0ee-bc99------4ef8-bb6d-6bb9-bd38-0a11", "a0ee-bc99------4ef8-bb6d-6bb9-bd38-0a11",
"{a0eebc99-bb6d6bb9-bd380a11}"].each do |invalid_uuid| "{a0eebc99-bb6d6bb9-bd380a11}",
"{a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11",
"a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11}"].each do |invalid_uuid|
uuid = UUIDType.new guid: invalid_uuid uuid = UUIDType.new guid: invalid_uuid
assert_nil uuid.guid assert_nil uuid.guid
end end