@@ -32,16 +32,18 @@ def initialize ss, class_loader, symbolize_names: false, freeze: false
32
32
33
33
def accept target
34
34
result = super
35
- return result if @domain_types . empty? || !target . tag
36
35
37
- key = target . tag . sub ( /^[!\/ ]*/ , '' ) . sub ( /(,\d +)\/ / , '\1:' )
38
- key = "tag:#{ key } " unless key =~ /^(?:tag:|x-private)/
36
+ unless @domain_types . empty? || !target . tag
37
+ key = target . tag . sub ( /^[!\/ ]*/ , '' ) . sub ( /(,\d +)\/ / , '\1:' )
38
+ key = "tag:#{ key } " unless key =~ /^(?:tag:|x-private)/
39
39
40
- if @domain_types . key? key
41
- value , block = @domain_types [ key ]
42
- return block . call value , result
40
+ if @domain_types . key? key
41
+ value , block = @domain_types [ key ]
42
+ result = block . call value , result
43
+ end
43
44
end
44
45
46
+ result = deduplicate ( result ) . freeze if @freeze
45
47
result
46
48
end
47
49
@@ -341,7 +343,7 @@ def revive_hash hash, o
341
343
key = accept ( k )
342
344
if @symbolize_names
343
345
key = key . to_sym
344
- else
346
+ elsif ! @freeze
345
347
key = deduplicate ( key )
346
348
end
347
349
val = accept ( v )
@@ -378,6 +380,8 @@ def revive_hash hash, o
378
380
if RUBY_VERSION < '2.7'
379
381
def deduplicate key
380
382
if key . is_a? ( String )
383
+ # It is important to untaint the string, otherwise it won't
384
+ # be deduplicated into an fstring, but simply frozen.
381
385
-( key . untaint )
382
386
else
383
387
key
0 commit comments