psych 3.2.0-java → 3.2.1-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: e956d1f39d537bbab914f9d69e070bc18268aa68ecf0ed219f515ae254409654
4
- data.tar.gz: c0a085a0afa83a1e78b8f4521a9904e4d800758ecdaff7efe9895faf060ad31c
3
+ metadata.gz: 41080752c6cb77f7ba4d02b6ecbe2ad1aa2c09d65a8517f382b058b0c6403eea
4
+ data.tar.gz: 811715a35a69851bc6bafece15c79044a90fa1f41f4244edf9f849f46bae6a42
5
5
  SHA512:
6
- metadata.gz: 07e866fdc5b8a36fd037ebc6fe1fffa585c4da0a53a997eb0e09fad12717a3bc91d8005fcd9648602b2008e8b648a028b7133291d1306c2c6998a0e15f4be170
7
- data.tar.gz: e31fe82bdef97efab8bb201a9fdb06eeafd94413890b2f890087ca15780738e137be16cac2680d2c40bed3a93e32836fa4819494c047e482c9784c8b22229db7
6
+ metadata.gz: 24f57e51181b8e2e37fe56521ff187259af539d1fd5857ffa07702e398ae1fdf2a7675bc528249afb860e6bab6eee77aa0fcbe89d75b762cd3a1895e6e44abcd
7
+ data.tar.gz: 63f862bae8f2abf207bc0b27e4b473820188b4e4ae0f1e0d774a76c641dad97c83fa29021a237e40ecfb1ece05560843936630618a005bd530954fde216fdf2b
data/README.md CHANGED
@@ -12,8 +12,8 @@ serialize and de-serialize most Ruby objects to and from the YAML format.
12
12
  ## Examples
13
13
 
14
14
  ```ruby
15
- # Load YAML in to a Ruby object
16
- Psych.load('--- foo') # => 'foo'
15
+ # Safely load YAML in to a Ruby object
16
+ Psych.safe_load('--- foo') # => 'foo'
17
17
 
18
18
  # Emit YAML from a Ruby object
19
19
  Psych.dump("foo") # => "--- foo\n...\n"
@@ -74,12 +74,15 @@ require 'psych/class_loader'
74
74
  #
75
75
  # ==== Reading from a string
76
76
  #
77
- # Psych.load("--- a") # => 'a'
78
- # Psych.load("---\n - a\n - b") # => ['a', 'b']
77
+ # Psych.safe_load("--- a") # => 'a'
78
+ # Psych.safe_load("---\n - a\n - b") # => ['a', 'b']
79
+ # # From a trusted string:
80
+ # Psych.load("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n") # => 0..42
79
81
  #
80
82
  # ==== Reading from a file
81
83
  #
82
- # Psych.load_file("database.yml")
84
+ # Psych.safe_load_file("data.yml", permitted_classes: [Date])
85
+ # Psych.load_file("trusted_database.yml")
83
86
  #
84
87
  # ==== Exception handling
85
88
  #
@@ -276,8 +279,7 @@ module Psych
276
279
 
277
280
  result = parse(yaml, filename: filename)
278
281
  return fallback unless result
279
- result = result.to_ruby(symbolize_names: symbolize_names, freeze: freeze) if result
280
- result
282
+ result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
281
283
  end
282
284
 
283
285
  ###
@@ -549,7 +551,7 @@ module Psych
549
551
  # end
550
552
  # list # => ['foo', 'bar']
551
553
  #
552
- def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
554
+ def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: [], **kwargs
553
555
  if legacy_filename != NOT_GIVEN
554
556
  warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
555
557
  filename = legacy_filename
@@ -557,10 +559,10 @@ module Psych
557
559
 
558
560
  result = if block_given?
559
561
  parse_stream(yaml, filename: filename) do |node|
560
- yield node.to_ruby
562
+ yield node.to_ruby(**kwargs)
561
563
  end
562
564
  else
563
- parse_stream(yaml, filename: filename).children.map(&:to_ruby)
565
+ parse_stream(yaml, filename: filename).children.map { |node| node.to_ruby(**kwargs) }
564
566
  end
565
567
 
566
568
  return fallback if result.is_a?(Array) && result.empty?
@@ -571,9 +573,24 @@ module Psych
571
573
  # Load the document contained in +filename+. Returns the yaml contained in
572
574
  # +filename+ as a Ruby object, or if the file is empty, it returns
573
575
  # the specified +fallback+ return value, which defaults to +false+.
574
- def self.load_file filename, fallback: false
576
+ #
577
+ # NOTE: This method *should not* be used to parse untrusted documents, such as
578
+ # YAML documents that are supplied via user input. Instead, please use the
579
+ # safe_load_file method.
580
+ def self.load_file filename, **kwargs
581
+ File.open(filename, 'r:bom|utf-8') { |f|
582
+ self.load f, filename: filename, **kwargs
583
+ }
584
+ end
585
+
586
+ ###
587
+ # Safely loads the document contained in +filename+. Returns the yaml contained in
588
+ # +filename+ as a Ruby object, or if the file is empty, it returns
589
+ # the specified +fallback+ return value, which defaults to +false+.
590
+ # See safe_load for options.
591
+ def self.safe_load_file filename, **kwargs
575
592
  File.open(filename, 'r:bom|utf-8') { |f|
576
- self.load f, filename: filename, fallback: fallback
593
+ self.safe_load f, filename: filename, **kwargs
577
594
  }
578
595
  end
579
596
 
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '3.2.0'
5
+ VERSION = '3.2.1'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
8
  DEFAULT_SNAKEYAML_VERSION = '1.26'.freeze
@@ -46,7 +46,6 @@ DESCRIPTION
46
46
  s.extra_rdoc_files = ["README.md"]
47
47
 
48
48
  s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
49
- s.rubygems_version = "2.5.1"
50
49
  s.required_rubygems_version = Gem::Requirement.new(">= 0")
51
50
 
52
51
  if RUBY_ENGINE == 'jruby'
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: 3.2.0
4
+ version: 3.2.1
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: 2020-07-17 00:00:00.000000000 Z
13
+ date: 2020-12-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement