File: drop-dependency-on-safe_yaml.patch

package info (click to toggle)
ruby-faraday-middleware 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 376 kB
  • sloc: ruby: 2,388; sh: 15; makefile: 6
file content (56 lines) | stat: -rw-r--r-- 2,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From: Antonio Terceiro <terceiro@debian.org>
Date: Fri, 27 Jan 2023 00:50:45 +0100
Subject: Drop dependency on safe_yaml

safe_yaml is buggy and will probably never be fixed (in time) for Bookworm.

Acked-by: Daniel Leidert <dleidert@debian.org>
Origin: https://lists.debian.org/debian-ruby/2023/01/msg00053.html
---
 lib/faraday_middleware/response/parse_yaml.rb | 4 ++--
 spec/unit/parse_yaml_spec.rb                  | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/faraday_middleware/response/parse_yaml.rb b/lib/faraday_middleware/response/parse_yaml.rb
index bf8873b..eb0f751 100644
--- a/lib/faraday_middleware/response/parse_yaml.rb
+++ b/lib/faraday_middleware/response/parse_yaml.rb
@@ -27,10 +27,10 @@ module FaradayMiddleware
   #       ...
   #     end
   class ParseYaml < ResponseMiddleware
-    dependency 'safe_yaml/load'
+    dependency 'yaml'
 
     define_parser do |body, parser_options|
-      SafeYAML.load(body, nil, parser_options || {})
+      YAML.safe_load(body, **(parser_options || {})) || false
     end
   end
 end
diff --git a/spec/unit/parse_yaml_spec.rb b/spec/unit/parse_yaml_spec.rb
index 33c0312..1a0a3e5 100644
--- a/spec/unit/parse_yaml_spec.rb
+++ b/spec/unit/parse_yaml_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe FaradayMiddleware::ParseYaml, type: :response do
     expect { process('{!') }.to raise_error(Faraday::ParsingError)
   end
 
-  context 'SafeYAML options' do
+  context 'YAML options' do
     let(:body) { 'a: 1' }
     let(:result) { { a: 1 } }
     let(:options) do
@@ -61,9 +61,9 @@ RSpec.describe FaradayMiddleware::ParseYaml, type: :response do
       }
     end
 
-    it 'passes relevant options to SafeYAML load' do
-      expect(::SafeYAML).to receive(:load)
-        .with(body, nil, options[:parser_options])
+    it 'passes relevant options to YAML safe_load' do
+      expect(::YAML).to receive(:safe_load)
+        .with(body, options[:parser_options])
         .and_return(result)
 
       response = process(body)