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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54430f72d4e60d345913cc82f31d7e4a6281996cb69213fd3ca26c3da5ee26c4
4
- data.tar.gz: 02a5c1a3bd34089470506b97df067d4360f228c7d297610a41fc1109fa6f583e
3
+ metadata.gz: b31da54485c398a26cd10e3dec1ab3498a36a95edd598c61ff34ec544b6b73a6
4
+ data.tar.gz: 476898d5a9dbea84360caedb8b53274ffbe869bec0de5e3473c4a75cdc9c96c9
5
5
  SHA512:
6
- metadata.gz: 0ca2e2c4fa3dd2aa52d00519116dca3ad5d8a99bb1d20724c741409e2e362b64e0e23ccada1b8b11e60b93e3fef90dfa2e3f285d2d5e2dfe7ff73138761aeaf6
7
- data.tar.gz: a06a46f5c8d486194609c742b2fd105f9e1129db3665aa3eb73ffc88b259720b188c2b7fa7e9923461e20c9fcc662f2bbe462ab6a6021ca7f22920d597deca67
6
+ metadata.gz: 5d7efe52ceb22c90a351b2c32bda30f81843e903478b06779dba39f4fb5142ec738f5f8a2ae22124ce528b05ae7b7c8994c2becf92da1c568c1346f19e34c920
7
+ data.tar.gz: 3f5bf83fe16f1f67fe300148cd671b4838ff46630576d8e28caf15aaa28abed43377e30855e8eebd61b36446e9fff9a882dffef010c5defc961a1cc5d0eaee96
@@ -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
 
@@ -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
- INTEGER = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
17
- |[-+]?0[0-7_,]+ (?# base 8)
18
- |[-+]?(?:0|[1-9](?:[0-9]|,[0-9]|_[0-9])*) (?# base 10)
19
- |[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
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.gsub(/[,_]|\.([Ee]|$)/, '\1'))
98
+ Float(string.delete(',_').gsub(/\.([Ee]|$)/, '\1'))
92
99
  end
93
- elsif string.match?(INTEGER)
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.gsub(/[,_]/, ''))
110
+ Integer(string.delete(',_'))
104
111
  end
105
112
 
106
113
  ###
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '4.0.3'
5
+ VERSION = '4.0.4'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
8
  DEFAULT_SNAKEYAML_VERSION = '1.28'.freeze
@@ -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.3
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: 2021-12-20 00:00:00.000000000 Z
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.1.6
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