summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md33
-rw-r--r--Rakefile46
-rw-r--r--VERSION2
-rw-r--r--ext/json/ext/generator/generator.c2
-rw-r--r--json_pure.gemspec5
-rw-r--r--lib/json/common.rb10
-rw-r--r--lib/json/pure/parser.rb2
-rw-r--r--lib/json/version.rb2
-rw-r--r--tests/json_common_interface_test.rb56
9 files changed, 105 insertions, 53 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 92a1925..0d39f21 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,38 @@
# Changes
+## 2020-06-30 (2.3.1)
+
+* Spelling and grammar fixes for comments. Pull request #191 by Josh
+ Kline.
+* Enhance generic JSON and #generate docs. Pull request #347 by Victor
+ Shepelev.
+* Add :nodoc: for GeneratorMethods. Pull request #349 by Victor Shepelev.
+* Baseline changes to help (JRuby) development. Pull request #371 by Karol
+ Bucek.
+* Add metadata for rubygems.org. Pull request #379 by Alexandre ZANNI.
+* Remove invalid JSON.generate description from JSON module rdoc. Pull
+ request #384 by Jeremy Evans.
+* Test with TruffleRuby in CI. Pull request #402 by Benoit Daloze.
+* Rdoc enhancements. Pull request #413 by Burdette Lamar.
+* Fixtures/ are not being tested... Pull request #416 by Marc-André
+ Lafortune.
+* Use frozen string for hash key. Pull request #420 by Marc-André
+ Lafortune.
+* Added :call-seq: to RDoc for some methods. Pull request #422 by Burdette
+ Lamar.
+* Small typo fix. Pull request #423 by Marc-André Lafortune.
+
+## 2019-12-11 (2.3.0)
+ * Fix default of `create_additions` to always be `false` for `JSON(user_input)`
+ and `JSON.parse(user_input, nil)`.
+ Note that `JSON.load` remains with default `true` and is meant for internal
+ serialization of trusted data. [CVE-2020-10663]
+ * Fix passing args all #to_json in json/add/*.
+ * Fix encoding issues
+ * Fix issues of keyword vs positional parameter
+ * Fix JSON::Parser against bigdecimal updates
+ * Bug fixes to JRuby port
+
## 2019-02-21 (2.2.0)
* Adds support for 2.6 BigDecimal and ruby standard library Set datetype.
diff --git a/Rakefile b/Rakefile
index 0945a67..5b42292 100644
--- a/Rakefile
+++ b/Rakefile
@@ -78,50 +78,6 @@ task :install_ext => [ :compile, :install_pure, :install_ext_really ]
desc "Installing library (extension)"
task :install => :install_ext
-if defined?(Gem) and defined?(Gem::PackageTask)
- spec_pure = Gem::Specification.new do |s|
- s.name = 'json_pure'
- s.version = PKG_VERSION
- s.summary = PKG_TITLE
- s.description = "This is a JSON implementation in pure Ruby."
-
- s.files = PKG_FILES
-
- s.require_path = 'lib'
- s.add_development_dependency 'rake'
- s.add_development_dependency 'test-unit', '>= 2.0', '< 4.0'
-
- s.extra_rdoc_files << 'README.md'
- s.rdoc_options <<
- '--title' << 'JSON implemention for ruby' << '--main' << 'README.md'
- s.test_files.concat Dir['./tests/test_*.rb']
-
- s.author = "Florian Frank"
- s.email = "flori@ping.de"
- s.homepage = "http://flori.github.com/#{PKG_NAME}"
- s.license = 'Ruby'
- s.required_ruby_version = '>= 2.0'
- end
-
- desc 'Creates a json_pure.gemspec file'
- task :gemspec_pure => :version do
- File.open('json_pure.gemspec', 'w') do |gemspec|
- src = spec_pure.to_ruby
- src.gsub!(/# stub:.*/, "# This gemspec is generated automatically using `rake gemspec`.\n" \
- "# Do not modify directly.")
- gemspec.write src
- end
- end
-
- Gem::PackageTask.new(spec_pure) do |pkg|
- pkg.need_tar = true
- pkg.package_files = PKG_FILES
- end
-
- desc 'Alias for gemspec_pure'
- task :gemspec => [ :gemspec_pure ]
-end
-
desc m = "Writing version information for #{PKG_VERSION}"
task :version do
puts m
@@ -375,4 +331,4 @@ else
end
desc "Compile in the the source directory"
-task :default => [ :clean, :gemspec, :test ]
+task :default => [ :clean, :test ]
diff --git a/VERSION b/VERSION
index 276cbf9..2bf1c1c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.0
+2.3.1
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
index ae60c4f..749efaf 100644
--- a/ext/json/ext/generator/generator.c
+++ b/ext/json/ext/generator/generator.c
@@ -1096,7 +1096,7 @@ static VALUE cState_generate(VALUE self, VALUE obj)
* generated, otherwise an exception is thrown, if these values are
* encountered. This options defaults to false.
* * *ascii_only*: true if only ASCII characters should be generated. This
- * ontions defaults to false.
+ * option defaults to false.
* * *buffer_initial_length*: sets the initial length of the generator's
* internal buffer.
*/
diff --git a/json_pure.gemspec b/json_pure.gemspec
index 7b4114a..007acd3 100644
--- a/json_pure.gemspec
+++ b/json_pure.gemspec
@@ -1,15 +1,12 @@
# -*- encoding: utf-8 -*-
-# This gemspec is generated automatically using `rake gemspec`.
-# Do not modify directly.
Gem::Specification.new do |s|
s.name = "json_pure".freeze
- s.version = "2.3.0"
+ s.version = File.read("VERSION").chomp
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Florian Frank".freeze]
- s.date = "2020-06-25"
s.description = "This is a JSON implementation in pure Ruby.".freeze
s.email = "flori@ping.de".freeze
s.extra_rdoc_files = ["README.md".freeze]
diff --git a/lib/json/common.rb b/lib/json/common.rb
index 6bec15b..132e9c8 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -201,6 +201,16 @@ module JSON
Parser.new(source, **(opts||{})).parse
end
+ # Parses the content of a file (see parse method documentation for more information).
+ def load_file(filespec, opts = {})
+ parse(File.read(filespec), opts)
+ end
+
+ # Parses the content of a file (see parse! method documentation for more information).
+ def load_file!(filespec, opts = {})
+ parse!(File.read(filespec), opts)
+ end
+
# :call-seq:
# JSON.generate(obj, opts = nil) -> new_string
#
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
index 1c8f59f..5db244c 100644
--- a/lib/json/pure/parser.rb
+++ b/lib/json/pure/parser.rb
@@ -49,7 +49,7 @@ module JSON
)+
)mx
- UNPARSED = Object.new.freeze
+ UNPARSED = Object.new.freeze
# Creates a new JSON::Pure::Parser instance for the string _source_.
#
diff --git a/lib/json/version.rb b/lib/json/version.rb
index 9d781df..e4dd3e3 100644
--- a/lib/json/version.rb
+++ b/lib/json/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module JSON
# JSON version
- VERSION = '2.3.0'
+ VERSION = '2.3.1'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
diff --git a/tests/json_common_interface_test.rb b/tests/json_common_interface_test.rb
index 53f335e..4fdc2b1 100644
--- a/tests/json_common_interface_test.rb
+++ b/tests/json_common_interface_test.rb
@@ -123,4 +123,60 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
assert_equal @json, JSON(@hash)
assert_equal @hash, JSON(@json)
end
+
+ def test_load_file
+ test_load_shared(:load_file)
+ end
+
+ def test_load_file!
+ test_load_shared(:load_file!)
+ end
+
+ def test_load_file_with_option
+ test_load_file_with_option_shared(:load_file)
+ end
+
+ def test_load_file_with_option!
+ test_load_file_with_option_shared(:load_file!)
+ end
+
+ private
+
+ def test_load_shared(method_name)
+ temp_file_containing(@json) do |filespec|
+ assert_equal JSON.public_send(method_name, filespec), @hash
+ end
+ end
+
+ def test_load_file_with_option_shared(method_name)
+ temp_file_containing(@json) do |filespec|
+ parsed_object = JSON.public_send(method_name, filespec, symbolize_names: true)
+ key_classes = parsed_object.keys.map(&:class)
+ assert_true key_classes.include?(Symbol) && (! key_classes.include?(String))
+ end
+ end
+
+ # Copied and slightly modified from https://github.com/keithrbennett/trick_bag
+ # (https://github.com/keithrbennett/trick_bag/blob/master/lib/trick_bag/io/temp_files.rb).
+ #
+ # For the easy creation and deletion of a temp file populated with text,
+ # wrapped around the code block you provide.
+ #
+ # @param text the text to write to the temporary file
+ # @param file_prefix optional prefix for the temporary file's name
+ # @yield filespec of the temporary file
+ def temp_file_containing(text, file_prefix = '')
+ raise "This method must be called with a code block." unless block_given?
+
+ filespec = nil
+ begin
+ Tempfile.open(file_prefix) do |file|
+ file << text
+ filespec = file.path
+ end
+ yield(filespec)
+ ensure
+ File.delete(filespec) if filespec && File.exist?(filespec)
+ end
+ end
end