Add Mail::YAML#load compatible with Psych 3.x and Psych 4.x.#1476
Add Mail::YAML#load compatible with Psych 3.x and Psych 4.x.#1476simi wants to merge 1 commit intomikel:masterfrom
Conversation
|
Very nice. Thx. This fixes the compatibility. Since there is check for the |
Hm, this is probably not very relevant 🙄 Nevertheless, how about: $ git diff
diff --git a/lib/mail/yaml.rb b/lib/mail/yaml.rb
index c0910855..b70da033 100644
--- a/lib/mail/yaml.rb
+++ b/lib/mail/yaml.rb
@@ -2,15 +2,23 @@ require 'yaml'
module Mail
module YAML
- # unsafe loading compatible with Psych 3.x and Psych 4.x
- if ::YAML.respond_to?(:unsafe_load)
- def self.load(yaml)
- ::YAML.unsafe_load(yaml)
- end
- else
- def self.load(yaml)
- ::YAML.load(yaml)
- end
+ def self.load(yaml)
+ ::YAML.load(yaml, :permitted_classes => [
+ Symbol,
+
+ Mail::Body,
+
+ # Delivery methods as listed in mail/configuration.rb
+ Mail::SMTP,
+ Mail::Sendmail,
+ Mail::Exim,
+ Mail::FileDelivery,
+ Mail::SMTPConnection,
+ Mail::TestMailer,
+ Mail::LoggerDelivery,
+
+ Mail.delivery_method.class,
+ ])
end
end
end |
|
Hey there @voxik thanks for the help on creating this. I just kicked off the workflows and looks like we have some failures on 1.9, 2.0, 2.2, 2.7 and latest. Can you take a quick look at those and see if we can fix those up? cc @deivid-rodriguez |
|
Sorry I'm late to the party :) Happy to help get these 3.x PRs resolved and merged and a new gem released asap. |
|
My recall about current failures from working on #1472:
So I think this PR should be fine! |
This is 1:1 transition. It would be great to be able to use "safe" load, but since custom classes could be serialised, it is not easily possible for now.
Btw. the best would be to be able to migrate to Psych 4, but it seems impossible since EOL Rubies are supported.
@voxik @deivid-rodriguez