psych 4.0.3-java → 4.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/psych/nodes/node.rb +2 -2
- data/lib/psych/scalar_scanner.rb +17 -10
- data/lib/psych/versions.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +2 -2
- data/lib/psych.jar +0 -0
- data/lib/psych.rb +7 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b31da54485c398a26cd10e3dec1ab3498a36a95edd598c61ff34ec544b6b73a6
|
4
|
+
data.tar.gz: 476898d5a9dbea84360caedb8b53274ffbe869bec0de5e3473c4a75cdc9c96c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d7efe52ceb22c90a351b2c32bda30f81843e903478b06779dba39f4fb5142ec738f5f8a2ae22124ce528b05ae7b7c8994c2becf92da1c568c1346f19e34c920
|
7
|
+
data.tar.gz: 3f5bf83fe16f1f67fe300148cd671b4838ff46630576d8e28caf15aaa28abed43377e30855e8eebd61b36446e9fff9a882dffef010c5defc961a1cc5d0eaee96
|
data/lib/psych/nodes/node.rb
CHANGED
@@ -46,8 +46,8 @@ module Psych
|
|
46
46
|
# Convert this node to Ruby.
|
47
47
|
#
|
48
48
|
# See also Psych::Visitors::ToRuby
|
49
|
-
def to_ruby(symbolize_names: false, freeze: false)
|
50
|
-
Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze).accept(self)
|
49
|
+
def to_ruby(symbolize_names: false, freeze: false, strict_integer: false)
|
50
|
+
Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer).accept(self)
|
51
51
|
end
|
52
52
|
alias :transform :to_ruby
|
53
53
|
|
data/lib/psych/scalar_scanner.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'strscan'
|
3
2
|
|
4
3
|
module Psych
|
5
4
|
###
|
@@ -13,24 +12,32 @@ module Psych
|
|
13
12
|
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10))$/x
|
14
13
|
|
15
14
|
# Taken from http://yaml.org/type/int.html
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
INTEGER_STRICT = /^(?:[-+]?0b[0-1_]+ (?# base 2)
|
16
|
+
|[-+]?0[0-7_]+ (?# base 8)
|
17
|
+
|[-+]?(0|[1-9][0-9_]*) (?# base 10)
|
18
|
+
|[-+]?0x[0-9a-fA-F_]+ (?# base 16))$/x
|
19
|
+
|
20
|
+
# Same as above, but allows commas.
|
21
|
+
# Not to YML spec, but kept for backwards compatibility
|
22
|
+
INTEGER_LEGACY = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
|
23
|
+
|[-+]?0[0-7_,]+ (?# base 8)
|
24
|
+
|[-+]?(?:0|[1-9](?:[0-9]|,[0-9]|_[0-9])*) (?# base 10)
|
25
|
+
|[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
|
20
26
|
|
21
27
|
attr_reader :class_loader
|
22
28
|
|
23
29
|
# Create a new scanner
|
24
|
-
def initialize class_loader
|
30
|
+
def initialize class_loader, strict_integer: false
|
25
31
|
@symbol_cache = {}
|
26
32
|
@class_loader = class_loader
|
33
|
+
@strict_integer = strict_integer
|
27
34
|
end
|
28
35
|
|
29
36
|
# Tokenize +string+ returning the Ruby object
|
30
37
|
def tokenize string
|
31
38
|
return nil if string.empty?
|
32
39
|
return @symbol_cache[string] if @symbol_cache.key?(string)
|
33
|
-
|
40
|
+
integer_regex = @strict_integer ? INTEGER_STRICT : INTEGER_LEGACY
|
34
41
|
# Check for a String type, being careful not to get caught by hash keys, hex values, and
|
35
42
|
# special floats (e.g., -.inf).
|
36
43
|
if string.match?(%r{^[^\d.:-]?[[:alpha:]_\s!@#$%\^&*(){}<>|/\\~;=]+}) || string.match?(/\n/)
|
@@ -88,9 +95,9 @@ module Psych
|
|
88
95
|
if string.match?(/\A[-+]?\.\Z/)
|
89
96
|
string
|
90
97
|
else
|
91
|
-
Float(string.
|
98
|
+
Float(string.delete(',_').gsub(/\.([Ee]|$)/, '\1'))
|
92
99
|
end
|
93
|
-
elsif string.match?(
|
100
|
+
elsif string.match?(integer_regex)
|
94
101
|
parse_int string
|
95
102
|
else
|
96
103
|
string
|
@@ -100,7 +107,7 @@ module Psych
|
|
100
107
|
###
|
101
108
|
# Parse and return an int from +string+
|
102
109
|
def parse_int string
|
103
|
-
Integer(string.
|
110
|
+
Integer(string.delete(',_'))
|
104
111
|
end
|
105
112
|
|
106
113
|
###
|
data/lib/psych/versions.rb
CHANGED
@@ -12,9 +12,9 @@ module Psych
|
|
12
12
|
###
|
13
13
|
# This class walks a YAML AST, converting each node to Ruby
|
14
14
|
class ToRuby < Psych::Visitors::Visitor
|
15
|
-
def self.create(symbolize_names: false, freeze: false)
|
15
|
+
def self.create(symbolize_names: false, freeze: false, strict_integer: false)
|
16
16
|
class_loader = ClassLoader.new
|
17
|
-
scanner = ScalarScanner.new class_loader
|
17
|
+
scanner = ScalarScanner.new class_loader, strict_integer: strict_integer
|
18
18
|
new(scanner, class_loader, symbolize_names: symbolize_names, freeze: freeze)
|
19
19
|
end
|
20
20
|
|
data/lib/psych.jar
CHANGED
Binary file
|
data/lib/psych.rb
CHANGED
@@ -268,12 +268,11 @@ module Psych
|
|
268
268
|
# YAML documents that are supplied via user input. Instead, please use the
|
269
269
|
# load method or the safe_load method.
|
270
270
|
#
|
271
|
-
def self.unsafe_load yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false
|
271
|
+
def self.unsafe_load yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false, strict_integer: false
|
272
272
|
result = parse(yaml, filename: filename)
|
273
273
|
return fallback unless result
|
274
|
-
result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
|
274
|
+
result.to_ruby(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer)
|
275
275
|
end
|
276
|
-
class << self; alias :load :unsafe_load; end
|
277
276
|
|
278
277
|
###
|
279
278
|
# Safely load the yaml string in +yaml+. By default, only the following
|
@@ -320,13 +319,13 @@ module Psych
|
|
320
319
|
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
321
320
|
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
322
321
|
#
|
323
|
-
def self.safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false
|
322
|
+
def self.safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false
|
324
323
|
result = parse(yaml, filename: filename)
|
325
324
|
return fallback unless result
|
326
325
|
|
327
326
|
class_loader = ClassLoader::Restricted.new(permitted_classes.map(&:to_s),
|
328
327
|
permitted_symbols.map(&:to_s))
|
329
|
-
scanner = ScalarScanner.new class_loader
|
328
|
+
scanner = ScalarScanner.new class_loader, strict_integer: strict_integer
|
330
329
|
visitor = if aliases
|
331
330
|
Visitors::ToRuby.new scanner, class_loader, symbolize_names: symbolize_names, freeze: freeze
|
332
331
|
else
|
@@ -366,14 +365,15 @@ module Psych
|
|
366
365
|
# Raises a TypeError when `yaml` parameter is NilClass. This method is
|
367
366
|
# similar to `safe_load` except that `Symbol` objects are allowed by default.
|
368
367
|
#
|
369
|
-
def self.load yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false
|
368
|
+
def self.load yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false
|
370
369
|
safe_load yaml, permitted_classes: permitted_classes,
|
371
370
|
permitted_symbols: permitted_symbols,
|
372
371
|
aliases: aliases,
|
373
372
|
filename: filename,
|
374
373
|
fallback: fallback,
|
375
374
|
symbolize_names: symbolize_names,
|
376
|
-
freeze: freeze
|
375
|
+
freeze: freeze,
|
376
|
+
strict_integer: strict_integer
|
377
377
|
end
|
378
378
|
|
379
379
|
###
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements:
|
140
140
|
- jar org.yaml:snakeyaml, 1.28
|
141
|
-
rubygems_version: 3.
|
141
|
+
rubygems_version: 3.2.29
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Psych is a YAML parser and emitter
|