Sha256: 77a8352e645f6f34fa82a6c97431b1ad2cdc72f08c69610e3c268b16b88b66a5
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
require 'faraday_middleware/response_middleware' module FaradayMiddleware # Public: Parse response bodies as YAML. # # Warning: This is not backwards compatible with versions of this middleware prior to # faraday_middleware v0.12 - prior to this version, we used YAML.load rather than # YAMl.safe_load, which exposes serious remote code execution risks - see # https://github.com/ruby/psych/issues/119 for details. If you're sure you can trust # YAML you're passing, you can set up an unsafe version of this middleware as follows: # # class UnsafelyParseYaml < FaradayMiddleware::ResponseMiddleware # dependency do # require 'yaml' # end # # define_parser do |body| # YAML.load body # end # end # # Faraday.new(..) do |config| # config.use UnsafelyParseYaml # ... # end class ParseYaml < ResponseMiddleware dependency 'safe_yaml/load' define_parser do |body, parser_options| if SafeYAML::YAML_ENGINE == 'psych' SafeYAML.load(body, nil, parser_options || {}) else SafeYAML.load(body, parser_options || {}) end end end end # deprecated alias Faraday::Response::ParseYaml = FaradayMiddleware::ParseYaml
Version data entries
4 entries across 4 versions & 1 rubygems