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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +1 -5
- data/lib/gon/base.rb +6 -3
- data/lib/gon/compatibility/old_rails.rb +2 -0
- data/lib/gon/env_finder.rb +2 -0
- data/lib/gon/escaper.rb +2 -0
- data/lib/gon/global.rb +2 -0
- data/lib/gon/helpers.rb +2 -0
- data/lib/gon/jbuilder/parser.rb +6 -4
- data/lib/gon/jbuilder.rb +3 -1
- data/lib/gon/json_dumper.rb +18 -1
- data/lib/gon/rabl.rb +3 -1
- data/lib/gon/request.rb +2 -0
- data/lib/gon/spec_helpers.rb +3 -1
- data/lib/gon/version.rb +3 -1
- data/lib/gon/watch.rb +2 -0
- data/lib/gon.rb +2 -0
- metadata +21 -38
- data/.github/FUNDING.yml +0 -1
- data/.gitignore +0 -7
- data/.travis.yml +0 -12
- data/Gemfile +0 -6
- data/Rakefile +0 -10
- data/doc/logo.png +0 -0
- data/doc/logo_small.png +0 -0
- data/doc/top_sample.png +0 -0
- data/gon.gemspec +0 -30
- data/spec/gon/basic_spec.rb +0 -304
- data/spec/gon/global_spec.rb +0 -146
- data/spec/gon/jbuilder_spec.rb +0 -75
- data/spec/gon/rabl_spec.rb +0 -90
- data/spec/gon/templates_spec.rb +0 -36
- data/spec/gon/thread_spec.rb +0 -39
- data/spec/gon/watch_spec.rb +0 -81
- data/spec/spec_helper.rb +0 -36
- data/spec/test_data/_sample_partial.json.jbuilder +0 -1
- data/spec/test_data/sample.json.jbuilder +0 -1
- data/spec/test_data/sample.rabl +0 -2
- data/spec/test_data/sample_rabl_rails.rabl +0 -2
- data/spec/test_data/sample_url_helpers.json.jbuilder +0 -1
- data/spec/test_data/sample_with_controller_method.json.jbuilder +0 -2
- data/spec/test_data/sample_with_helpers.json.jbuilder +0 -1
- data/spec/test_data/sample_with_helpers.rabl +0 -3
- data/spec/test_data/sample_with_helpers_rabl_rails.rabl +0 -3
- data/spec/test_data/sample_with_locals.json.jbuilder +0 -2
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764e0fdc60fe7b018d593c4f10ac5da1b27c117b6c2f0bcd62eea6d04a91a571
|
4
|
+
data.tar.gz: 037f1aa29e3e2865c576dfd3dc70e4931b96ca59732d1067ef1c72bad53d8006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
[](https://gitter.im/gazay/gon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
-
|
5
3
|

|
6
4
|
|
7
|
-
[](https://travis-ci.org/gazay/gon) [](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/
|
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
|
-
|
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 =
|
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
|
|
data/lib/gon/env_finder.rb
CHANGED
data/lib/gon/escaper.rb
CHANGED
data/lib/gon/global.rb
CHANGED
data/lib/gon/helpers.rb
CHANGED
data/lib/gon/jbuilder/parser.rb
CHANGED
@@ -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.
|
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.
|
112
|
-
return "#{path}.jbuilder" if File.
|
113
|
-
return "#{path}.json.jbuilder" if File.
|
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
|
data/lib/gon/json_dumper.rb
CHANGED
@@ -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
data/lib/gon/spec_helpers.rb
CHANGED
@@ -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
data/lib/gon/watch.rb
CHANGED
data/lib/gon.rb
CHANGED
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.
|
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:
|
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
|
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
|
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.
|
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
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
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
|