gon 6.3.2 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -1
  3. data/README.md +1 -5
  4. data/lib/gon/base.rb +6 -3
  5. data/lib/gon/compatibility/old_rails.rb +2 -0
  6. data/lib/gon/env_finder.rb +2 -0
  7. data/lib/gon/escaper.rb +2 -0
  8. data/lib/gon/global.rb +2 -0
  9. data/lib/gon/helpers.rb +2 -0
  10. data/lib/gon/jbuilder/parser.rb +6 -4
  11. data/lib/gon/jbuilder.rb +3 -1
  12. data/lib/gon/json_dumper.rb +18 -1
  13. data/lib/gon/rabl.rb +3 -1
  14. data/lib/gon/request.rb +2 -0
  15. data/lib/gon/spec_helpers.rb +3 -1
  16. data/lib/gon/version.rb +3 -1
  17. data/lib/gon/watch.rb +2 -0
  18. data/lib/gon.rb +2 -0
  19. metadata +21 -38
  20. data/.github/FUNDING.yml +0 -1
  21. data/.gitignore +0 -7
  22. data/.travis.yml +0 -12
  23. data/Gemfile +0 -6
  24. data/Rakefile +0 -10
  25. data/doc/logo.png +0 -0
  26. data/doc/logo_small.png +0 -0
  27. data/doc/top_sample.png +0 -0
  28. data/gon.gemspec +0 -30
  29. data/spec/gon/basic_spec.rb +0 -304
  30. data/spec/gon/global_spec.rb +0 -146
  31. data/spec/gon/jbuilder_spec.rb +0 -75
  32. data/spec/gon/rabl_spec.rb +0 -90
  33. data/spec/gon/templates_spec.rb +0 -36
  34. data/spec/gon/thread_spec.rb +0 -39
  35. data/spec/gon/watch_spec.rb +0 -81
  36. data/spec/spec_helper.rb +0 -36
  37. data/spec/test_data/_sample_partial.json.jbuilder +0 -1
  38. data/spec/test_data/sample.json.jbuilder +0 -1
  39. data/spec/test_data/sample.rabl +0 -2
  40. data/spec/test_data/sample_rabl_rails.rabl +0 -2
  41. data/spec/test_data/sample_url_helpers.json.jbuilder +0 -1
  42. data/spec/test_data/sample_with_controller_method.json.jbuilder +0 -2
  43. data/spec/test_data/sample_with_helpers.json.jbuilder +0 -1
  44. data/spec/test_data/sample_with_helpers.rabl +0 -3
  45. data/spec/test_data/sample_with_helpers_rabl_rails.rabl +0 -3
  46. data/spec/test_data/sample_with_locals.json.jbuilder +0 -2
  47. data/spec/test_data/sample_with_partial.json.jbuilder +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4be940f45c3dff8c909d94552a81b3240ccea1dd42d5c442c18400278564286
4
- data.tar.gz: 86efc334a694c3a9825ec909f34bd5138b601de0108172863adb4d651eccdb28
3
+ metadata.gz: 764e0fdc60fe7b018d593c4f10ac5da1b27c117b6c2f0bcd62eea6d04a91a571
4
+ data.tar.gz: 037f1aa29e3e2865c576dfd3dc70e4931b96ca59732d1067ef1c72bad53d8006
5
5
  SHA512:
6
- metadata.gz: 9adb780569a41eb32cf547f7ffebf22b184fdda8c63aa6d7c2e5e9b0efe789e2ec5a187cec83d4ca4ef0bc068148708adf1a7541752dcad83228dc4c5cf08920
7
- data.tar.gz: da49fd8d8e2b683bd69fa2e5f37e8f912faa4496a3f81739022b68f2bea5cd1762c0b3b54c25426756499e8096c9822ff36ce7e854e771db28237988c5e4385b
6
+ metadata.gz: c1de2c9a8f8c3d571fe8d9eff0cf742e23b8f5be0ff133e59fbd3dc1157ec108c1cf4ea0a00b486e6f2be4e883cb5405af1857ba345002b4c647222698e5471f
7
+ data.tar.gz: ac19fa38ca794c863ede248e6a6a581f9417f5a59f5f4d836760280933c2f656a43e8048cd801f3fb1587c4d79bf86a7f00c21c711f264cd83d09aa05d9a3405
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [6.4.0] - 2020-09-18
6
+ ### Security
7
+ - CVE-2020-25739: Enforce HTML entities escaping in gon output
8
+
5
9
  ## [6.3.2] - 2019-11-18
6
10
  ### Security
7
11
  - Restrict possibility of vulnerable i18n legacy verision (0.3.6.pre)
@@ -226,7 +230,9 @@
226
230
  ### Changed
227
231
  - Don't really remember what was before this version
228
232
 
229
- [Unreleased]: https://github.com/gazay/gon/compare/v6.3.1...master
233
+ [Unreleased]: https://github.com/gazay/gon/compare/v6.4.0...master
234
+ [6.4.0]: https://github.com/gazay/gon/compare/v6.3.2...v6.4.0
235
+ [6.3.2]: https://github.com/gazay/gon/compare/v6.3.1...v6.3.2
230
236
  [6.3.1]: https://github.com/gazay/gon/compare/v6.2.1...v6.3.1
231
237
  [6.2.1]: https://github.com/gazay/gon/compare/v6.2.0...v6.2.1
232
238
  [6.2.0]: https://github.com/gazay/gon/compare/v6.1.0...v6.2.0
data/README.md CHANGED
@@ -1,11 +1,7 @@
1
1
  # Gon gem — get your Rails variables in your js
2
2
 
3
- [![Join the chat at https://gitter.im/gazay/gon](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gazay/gon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
-
5
3
  ![Gon. You should try this. If you look closer - you will see an elephant.](https://github.com/gazay/gon/raw/master/doc/logo_small.png)
6
4
 
7
- [![Build Status](https://travis-ci.org/gazay/gon.svg?branch=master)](https://travis-ci.org/gazay/gon) [![CodeClimate](https://codeclimate.com/github/gazay/gon/badges/gpa.svg)](https://codeclimate.com/github/gazay/gon)
8
-
9
5
  If you need to send some data to your js files and you don't want to do this with long way through views and parsing - use this force!
10
6
 
11
7
  Now you can easily renew data in your variables through ajax with [gon.watch](https://github.com/gazay/gon/wiki/Usage-gon-watch)!
@@ -224,7 +220,7 @@ usage gon.global.
224
220
 
225
221
  ## Speed up Gon
226
222
 
227
- You can use any [JSON Engine](https://github.com/intridea/multi_json#supported-json-engines) you want.
223
+ You can use any [JSON Engine](https://github.com/sferik/multi_json#supported-json-engines) you want.
228
224
  Gon uses `MultiJson` with autodetect mode, so all you need is just require your JSON library.
229
225
 
230
226
  ## Contributors
data/lib/gon/base.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'ostruct'
1
+ # frozen_string_literal: true
2
2
 
3
3
  class Gon
4
4
  module Base
@@ -16,6 +16,9 @@ class Gon
16
16
  nonce: nil
17
17
  }
18
18
 
19
+ Option = Struct.new(:cameled, *VALID_OPTION_DEFAULTS.keys)
20
+ private_constant :Option
21
+
19
22
  class << self
20
23
 
21
24
  def render_data(options = {})
@@ -31,7 +34,7 @@ class Gon
31
34
  private
32
35
 
33
36
  def define_options(options)
34
- _o = OpenStruct.new
37
+ _o = Option.new
35
38
 
36
39
  VALID_OPTION_DEFAULTS.each do |opt_name, default|
37
40
  _o.send("#{opt_name}=", options.fetch(opt_name, default))
@@ -43,7 +46,7 @@ class Gon
43
46
  end
44
47
 
45
48
  def formatted_data(_o)
46
- script = ''
49
+ script = +''
47
50
  before, after = render_wrap(_o)
48
51
  script << before
49
52
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  class Gon
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module EnvFinder
3
5
  ENV_CONTROLLER_KEY = 'action_controller.instance'
data/lib/gon/escaper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Escaper
3
5
  extend ActionView::Helpers::JavaScriptHelper
data/lib/gon/global.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Global < Gon
3
5
  class << self
data/lib/gon/helpers.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module ViewHelpers
3
5
  def include_gon(options = {})
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Jbuilder
3
5
  class Parser
@@ -91,7 +93,7 @@ class Gon
91
93
  end
92
94
 
93
95
  def parse_path(path)
94
- return path if File.exists?(path)
96
+ return path if File.exist?(path)
95
97
  if (splitted = path.split('/')).blank?
96
98
  raise 'Something wrong with partial path in your jbuilder templates'
97
99
  elsif splitted.size == 1
@@ -108,9 +110,9 @@ class Gon
108
110
  end
109
111
 
110
112
  def path_with_ext(path)
111
- return path if File.exists?(path)
112
- return "#{path}.jbuilder" if File.exists?("#{path}.jbuilder")
113
- return "#{path}.json.jbuilder" if File.exists?("#{path}.json.jbuilder")
113
+ return path if File.exist?(path)
114
+ return "#{path}.jbuilder" if File.exist?("#{path}.jbuilder")
115
+ return "#{path}.json.jbuilder" if File.exist?("#{path}.json.jbuilder")
114
116
  end
115
117
 
116
118
  def find_partials(lines = [])
data/lib/gon/jbuilder.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Jbuilder
3
5
  class << self
@@ -30,7 +32,7 @@ class Gon
30
32
 
31
33
  def parse_options_from(args)
32
34
  if old_api? args
33
- text = "[DEPRECATION] view_path argument is now optional. "
35
+ text = +"[DEPRECATION] view_path argument is now optional. "
34
36
  text << "If you need to specify it, "
35
37
  text << "please use gon.jbuilder(:template => 'path')"
36
38
  warn text
@@ -1,8 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module JsonDumper
5
+ # Taken from ERB::Util
6
+ JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/u
7
+ JSON_ESCAPE = {
8
+ "&" => '\u0026',
9
+ ">" => '\u003e',
10
+ "<" => '\u003c',
11
+ "\u2028" => '\u2028',
12
+ "\u2029" => '\u2029'
13
+ }
14
+
3
15
  def self.dump(object)
4
- MultiJson.dump object,
16
+ dumped_json = MultiJson.dump object,
5
17
  mode: :compat, escape_mode: :xss_safe, time_format: :ruby
18
+ escape(dumped_json)
19
+ end
20
+
21
+ def self.escape(json)
22
+ json.gsub(JSON_ESCAPE_REGEXP, JSON_ESCAPE)
6
23
  end
7
24
  end
8
25
  end
data/lib/gon/rabl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'action_view'
2
4
 
3
5
  begin
@@ -63,7 +65,7 @@ class Gon
63
65
  def parse_options_from(args, global)
64
66
  if old_api? args
65
67
  unless global
66
- text = "[DEPRECATION] view_path argument is now optional. "
68
+ text = +"[DEPRECATION] view_path argument is now optional. "
67
69
  text << "If you need to specify it, "
68
70
  text << "please use gon.rabl(:template => 'path')"
69
71
  warn text
data/lib/gon/request.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Request
3
5
  attr_reader :env, :gon
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module SpecHelper
3
5
  module Rails
@@ -5,7 +7,7 @@ class Gon
5
7
 
6
8
  module ClassMethods
7
9
  module GonSession
8
- def process(*)
10
+ def process(*, **)
9
11
  # preload threadlocal & store controller instance
10
12
  if controller.is_a? ActionController::Base
11
13
  controller.gon
data/lib/gon/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
- VERSION = '6.3.2'
4
+ VERSION = '6.5.0'
3
5
  end
data/lib/gon/watch.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Watch < Gon
3
5
  class << self
data/lib/gon.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'request_store'
2
4
  require 'action_view'
3
5
  require 'action_controller'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.2
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gazay
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
@@ -70,16 +69,16 @@ dependencies:
70
69
  name: rabl
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - '='
72
+ - - ">="
74
73
  - !ruby/object:Gem::Version
75
- version: 0.11.3
74
+ version: '0'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - '='
79
+ - - ">="
81
80
  - !ruby/object:Gem::Version
82
- version: 0.11.3
81
+ version: '0'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: rabl-rails
85
84
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +163,20 @@ dependencies:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
166
+ - !ruby/object:Gem::Dependency
167
+ name: pry-byebug
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
167
180
  description: If you need to send some data to your js files and you don't want to
168
181
  do this with long way trough views and parsing - use this force!
169
182
  email:
@@ -172,19 +185,10 @@ executables: []
172
185
  extensions: []
173
186
  extra_rdoc_files: []
174
187
  files:
175
- - ".github/FUNDING.yml"
176
- - ".gitignore"
177
- - ".travis.yml"
178
188
  - CHANGELOG.md
179
- - Gemfile
180
189
  - LICENSE
181
190
  - README.md
182
- - Rakefile
183
191
  - coffee/watch.coffee
184
- - doc/logo.png
185
- - doc/logo_small.png
186
- - doc/top_sample.png
187
- - gon.gemspec
188
192
  - js/watch.js
189
193
  - lib/gon.rb
190
194
  - lib/gon/base.rb
@@ -201,30 +205,10 @@ files:
201
205
  - lib/gon/spec_helpers.rb
202
206
  - lib/gon/version.rb
203
207
  - lib/gon/watch.rb
204
- - spec/gon/basic_spec.rb
205
- - spec/gon/global_spec.rb
206
- - spec/gon/jbuilder_spec.rb
207
- - spec/gon/rabl_spec.rb
208
- - spec/gon/templates_spec.rb
209
- - spec/gon/thread_spec.rb
210
- - spec/gon/watch_spec.rb
211
- - spec/spec_helper.rb
212
- - spec/test_data/_sample_partial.json.jbuilder
213
- - spec/test_data/sample.json.jbuilder
214
- - spec/test_data/sample.rabl
215
- - spec/test_data/sample_rabl_rails.rabl
216
- - spec/test_data/sample_url_helpers.json.jbuilder
217
- - spec/test_data/sample_with_controller_method.json.jbuilder
218
- - spec/test_data/sample_with_helpers.json.jbuilder
219
- - spec/test_data/sample_with_helpers.rabl
220
- - spec/test_data/sample_with_helpers_rabl_rails.rabl
221
- - spec/test_data/sample_with_locals.json.jbuilder
222
- - spec/test_data/sample_with_partial.json.jbuilder
223
208
  homepage: https://github.com/gazay/gon
224
209
  licenses:
225
210
  - MIT
226
211
  metadata: {}
227
- post_install_message:
228
212
  rdoc_options: []
229
213
  require_paths:
230
214
  - lib
@@ -239,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
223
  - !ruby/object:Gem::Version
240
224
  version: '0'
241
225
  requirements: []
242
- rubygems_version: 3.0.3
243
- signing_key:
226
+ rubygems_version: 3.6.9
244
227
  specification_version: 4
245
228
  summary: Get your Rails variables in your JS
246
229
  test_files: []
data/.github/FUNDING.yml DELETED
@@ -1 +0,0 @@
1
- tidelift: "rubygems/gon"
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- tmp/*
6
- .rvmrc
7
- *.idea
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- env:
4
- - "RABL_GEM=rabl"
5
- - "RABL_GEM=rabl-rails"
6
-
7
- rvm:
8
- - 2.2.10
9
- - 2.3.7
10
- - 2.4.4
11
- - 2.5.1
12
- - ruby-head
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gon.gemspec
4
- gem ENV['RABL_GEM'] || 'rabl'
5
-
6
- gemspec
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- desc 'Run all tests by default'
5
- task :default => :spec
6
-
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new do |t|
9
- t.rspec_opts = ["--color", '--format doc', '--require spec_helper']
10
- end
data/doc/logo.png DELETED
Binary file
data/doc/logo_small.png DELETED
Binary file
data/doc/top_sample.png DELETED
Binary file
data/gon.gemspec DELETED
@@ -1,30 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'gon/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'gon'
7
- s.version = Gon::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['gazay']
10
- s.licenses = ['MIT']
11
- s.email = ['alex.gaziev@gmail.com']
12
- s.homepage = 'https://github.com/gazay/gon'
13
- s.summary = %q{Get your Rails variables in your JS}
14
- s.description = %q{If you need to send some data to your js files and you don't want to do this with long way trough views and parsing - use this force!}
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.require_paths = ['lib']
18
- s.required_ruby_version = '>= 2.2.0'
19
- s.add_dependency 'actionpack', '>= 3.0.20'
20
- s.add_dependency 'i18n', '>= 0.7'
21
- s.add_dependency 'request_store', '>= 1.0'
22
- s.add_dependency 'multi_json'
23
- s.add_development_dependency 'rabl', '0.11.3'
24
- s.add_development_dependency 'rabl-rails'
25
- s.add_development_dependency 'rspec', '>= 3.0'
26
- s.add_development_dependency 'jbuilder'
27
- s.add_development_dependency 'railties', '>= 3.0.20'
28
- s.add_development_dependency 'rake'
29
- s.add_development_dependency 'pry'
30
- end