rabl 0.14.4 → 0.14.5

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: 319983ae5fd329b2650da09ab880866b0f07f4d81bc722a27c9d0305fd1a77af
4
- data.tar.gz: 7b6b13b88d7da8b770e1f4cc8aaa0d3193f50f01b0f57980a4ce8071538e4849
3
+ metadata.gz: 7f8f5c72fe30d17c5b7c2ae3aca6e6656d7ffe7328af4500a7bc05b768e4565e
4
+ data.tar.gz: bc687948b0f47252b5bc1adb82e93de1799accc7cfd4ed7dbb553229f8e5a0d4
5
5
  SHA512:
6
- metadata.gz: b1362d83db64761f01d4080168836f8eba428679b71d81b099aed9280b9b8a4514ad3ba02a318371eb1749a4321610e6da111f7a73450898894a702f075611be
7
- data.tar.gz: 0f321dcb3312a35df5f5381aa66af94a527c526c529922994346d8833c72ec986f8879de6050c7bc35dfbe333bc4257846ddb3d70d74406e94b0cab0c65aaaf3
6
+ metadata.gz: ae6541b60f172489bb74441ec17e2e47b8512793b3476b6dbcdd85db147437a23200817f8a78422a739043b3ebd824dfc8662bc5160058160579149bd1ffb840
7
+ data.tar.gz: 7e09471906df9571caff5afb224d0231fa9b9fc177d0422fbaf2d81cd631958b8bfbb802ec221965140b0214152f561172614b37967b0ccc8742886e9ec16dc5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.14.5 (May 29th, 2021)
4
+
5
+ * Restrict and validate the `to_***` methods available within engine (Brian McFadden)
6
+
3
7
  ## 0.14.4 (April 1st, 2021)
4
8
 
5
9
  * Test against latest Ruby versions
data/README.md CHANGED
@@ -184,9 +184,9 @@ If `replace_nil_values_with_empty_strings` is set to `true`, all values that are
184
184
 
185
185
  If `exclude_nil_values` is set to `true`, all values that are `nil` and would normally be displayed as `null` in the response are not included in the response.
186
186
 
187
- if `exclude_empty_values_in_collections` is set to `true`, all vaules in a collection that are `{}` and would normally be displayed as `{}` in the response are not included in the response.
187
+ if `exclude_empty_values_in_collections` is set to `true`, all values in a collection that are `{}` and would normally be displayed as `{}` in the response are not included in the response.
188
188
 
189
- If `camelize_keys` is set to `true`, all object keys will be converted to camel case. By default the first character will be lower case. The value can be set to `:upper` to set the first chracter to upper case.
189
+ If `camelize_keys` is set to `true`, all object keys will be converted to camel case. By default the first character will be lower case. The value can be set to `:upper` to set the first character to upper case.
190
190
 
191
191
  If you wish to use [oj](https://github.com/ohler55/oj) as
192
192
  the primary JSON encoding engine simply add that to your Gemfile:
data/lib/rabl/engine.rb CHANGED
@@ -6,6 +6,7 @@ module Rabl
6
6
 
7
7
  # List of supported rendering formats
8
8
  FORMATS = [:json, :xml, :plist, :bson, :msgpack]
9
+ SAFE_FORMATS = FORMATS + [:mpac, :dumpable, :hash]
9
10
 
10
11
  # Constructs a new ejs engine based on given vars, handler and declarations
11
12
  # Rabl::Engine.new("...source...", { :format => "xml", :root => true, :view_path => "/path/to/views" })
@@ -395,6 +396,10 @@ module Rabl
395
396
  defined?(Rails) && Rails.version =~ /^[456]/
396
397
  end
397
398
 
399
+ def valid_format?(format)
400
+ SAFE_FORMATS.include?(format.to_sym) && respond_to?("to_#{format}")
401
+ end
402
+
398
403
  def set_instance_variables!(context_scope, locals)
399
404
  @_context_scope = context_scope
400
405
  @_locals = locals || {}
@@ -403,6 +408,9 @@ module Rabl
403
408
 
404
409
  @_options[:format] ||= request_format
405
410
 
411
+ # Prevent calls to inherited methods `to_yaml`, `to_enum`, etc.
412
+ @_options[:format] = 'json' unless valid_format?(@_options[:format])
413
+
406
414
  set_locals(@_locals)
407
415
  end
408
416
 
data/lib/rabl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.14.4"
2
+ VERSION = "0.14.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-02 00:00:00.000000000 Z
11
+ date: 2021-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -169,7 +169,7 @@ homepage: https://github.com/nesquena/rabl
169
169
  licenses:
170
170
  - MIT
171
171
  metadata: {}
172
- post_install_message:
172
+ post_install_message:
173
173
  rdoc_options: []
174
174
  require_paths:
175
175
  - lib
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubygems_version: 3.0.6
188
- signing_key:
188
+ signing_key:
189
189
  specification_version: 4
190
190
  summary: General ruby templating with json, bson, xml and msgpack support
191
191
  test_files: []