summaryrefslogtreecommitdiff
path: root/ext/json/lib/json/common.rb
AgeCommit message (Collapse)Author
2024-04-04[flori/json] Autoload GenericObject to avoid require ostruct warning in Ruby 3.4tompng
https://github.com/flori/json/commit/b507f9e404
2023-12-05[flori/json] Fix JSON.dump overload combinationtompng
https://github.com/flori/json/commit/41c2712a3b
2023-12-05[flori/json] Overload kwargs in JSON.dumpTakashi Kokubun
https://github.com/flori/json/commit/936f280f9f
2023-12-05[flori/json] JSON.dump: handle unenclosed hashes regressionJean Boussier
Fix: https://github.com/flori/json/issues/553 We can never add keyword arguments to `dump` otherwise existing code using unenclosed hash will break. https://github.com/flori/json/commit/8e0076a3f2
2023-12-01Manually merged from flori/jsonHiroshi SHIBATA
> https://github.com/flori/json/pull/525 > Rename escape_slash in script_safe and also escape E+2028 and E+2029 Co-authored-by: Jean Boussier <jean.boussier@gmail.com> > https://github.com/flori/json/pull/454 > Remove unnecessary initialization of create_id in JSON.parse() Co-authored-by: Watson <watson1978@gmail.com>
2023-12-01Rename escape_slash in script_safe and also escape E+2028 and E+2029Jean Boussier
It is rather common to directly interpolate JSON string inside <script> tags in HTML as to provide configuration or parameters to a script. However this may lead to XSS vulnerabilities, to prevent that 3 characters need to be escaped: - `/` (forward slash) - `U+2028` (LINE SEPARATOR) - `U+2029` (PARAGRAPH SEPARATOR) The forward slash need to be escaped to prevent closing the script tag early, and the other two are valid JSON but invalid Javascript and can be used to break JS parsing. Given that the intent of escaping forward slash is the same than escaping U+2028 and U+2029, I chos to rename and repurpose the existing `escape_slash` option.
2023-07-19[flori/json] Remove unnecessary codeNobuyoshi Nakada
In `JSON#generate` and `JSON#fast_generate`: - When the given `opts` is a `JSON::State` the variable is set to `nil`. - But it will be never used as the next `if` blocks will not be executed. - `JSON::State#configure` does the conversion to `Hash`, the conversions in the `if` block are just duplication. - `JSON::State.new` does the same thing with `configure` when an argument is given. https://github.com/flori/json/commit/5d9ab87f8e Notes: Merged: https://github.com/ruby/ruby/pull/8091
2020-12-22Merge json-2.5.1Hiroshi SHIBATA
2020-12-22Prepare to release json-2.5.0Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/3975
2020-12-21[json] Avoid method redefinitionKenta Murata
2020-12-21[json] Make JSON.create_id thread-safeKenta Murata
2020-12-21[json] Stop using prototype objectsKenta Murata
2020-09-25[flori/json] Fix JSON.load_file docJean Boussier
https://github.com/flori/json/commit/cb61a00ba8 Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] Partial compliance with doc/method_documentation.rdocBurdetteLamar
https://github.com/flori/json/commit/6dfa885134 Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] Enhanced RDoc for JSON.dump (#443)Burdette Lamar
* Enhanced RDoc for JSON.dump https://github.com/flori/json/commit/03f1699ec4 Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] Nodoc for recurse_procBurdetteLamar
https://github.com/flori/json/commit/f8c0fe2408 Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] RDoc for JSON.load with procBurdetteLamar
https://github.com/flori/json/commit/a55c91934e Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] RDoc example for JSON.loadBurdetteLamar
https://github.com/flori/json/commit/e4eead665c Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] Enhance RDoc for JSON.parseBurdetteLamar
https://github.com/flori/json/commit/33e64ef255 Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] Move options from #generate and #parse to common areaBurdetteLamar
https://github.com/flori/json/commit/20d7be605a Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25[flori/json] Add `load_file` and `load_file!` methods, with tests. Fixes ↵Keith Bennett
issue #386. https://github.com/flori/json/commit/0be363c99b Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-09-25Add an option to escape forward slash characterJean Boussier
Squashed commit of the following: commit 26d181059989279a79c433cedcd893b4f52e42ee Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Tue Sep 15 21:17:34 2015 +0000 add config options for escape_slash commit fa282334051b16df91ca097dd7304b46f3bc7719 Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Mon Feb 9 21:09:33 2015 +0000 add forward slash to escape character Notes: Merged: https://github.com/ruby/ruby/pull/3581
2020-07-01[flori/json] Added :call-seq: to RDOc for some methodsBurdetteLamar
https://github.com/flori/json/commit/ee5b6a74e9
2020-07-01[flori/json] RDoc enhancementsBurdetteLamar
https://github.com/flori/json/commit/ada48f0236
2020-07-01[flori/json] RDoc enhancementsBurdetteLamar
https://github.com/flori/json/commit/470d909c0d
2020-07-01[flori/json] RDoc enhancementsBurdetteLamar
https://github.com/flori/json/commit/7bee2c7c13
2020-07-01[flori/json] Rdoc enhancementsBurdetteLamar
https://github.com/flori/json/commit/e7e3732130
2020-01-06[flori/json] Enchance generic JSON and #generate docszverok
https://github.com/flori/json/commit/4ede0a7d19
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2016-07-14* ext/json/**/*.rb: merge original files from upstream repository.hsbt
It only fixes styles of frozen string literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-05* ext/json/*, test/json/*: Update json-2.0.1.hsbt
Changes of 2.0.0: https://github.com/flori/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2015-09-11-200 Changes of 2.0.1: https://github.com/flori/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2016-07-01-201 [Feature #12542][ruby-dev:49706][fix GH-1395] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16handle ext/ as r53141naruse
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&# frozen_string_literal: false\n");f.rewind;f.write s}}' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12* ext/json/*, test/json/*: Reverted r50231. Because it's not works withhsbt
cross-compile environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-11* ext/json/*, test/json/*, defs/default_gems: Gemify JSON library.hsbt
[fix GH-867][Feature #11057] * test/ruby/test_extlibs.rb: removed json gem from existence extentions. * gems/bundled_gems: added json gem into bundled gem. * lib/rdoc/rubygems_hook.rb: ignored no json environment. * lib/rubygems/test_case.rb, test/rubygems/*: ditto. * lib/rdoc/test_case.rb, test/rdoc/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-28* ext/json, test/json: merge JSON HEAD(17fe8e7)hsbt
https://github.com/flori/json/compare/v1.8.1...17fe8e7 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27* lib/irb/notifier.rb: [Doc] Fix typoa_matsuda
* ext/json/lib/json/common.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-20* ext/json: merge JSON 1.8.1.naruse
https://github.com/nurse/json/compare/002ac2771ce32776b32ccd2d06e5604de6c36dcd...e09ffc0d7da25d0393873936c118c188c78dbac3 * Remove Rubinius exception since transcoding should be working now. * Fix https://github.com/flori/json/issues/162 reported by Marc-Andre Lafortune <github_rocks@marc-andre.ca>. Thanks! * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with -Wchar-subscripts and better validate UTF-8 strings. * Applied patch by ginriki@github to remove unnecessary if. * Add load/dump interface to JSON::GenericObject to make serialize :some_attribute, JSON::GenericObject work in Rails active models for convenient SomeModel#some_attribute.foo.bar access to serialised JSON data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09fixup stying of `Json#generate` parameter docs by @daveworth [fixes GH-339]hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-12* ext/json: merge JSON 1.7.7.naruse
This includes security fix. [CVE-2013-0269] https://github.com/flori/json/commit/d0a62f3ced7560daba2ad546d83f0479a5ae2cf2 https://groups.google.com/d/topic/rubyonrails-security/4_YvCpLzL58/discussion git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12* ext/json: merge JSON 1.7.5.naruse
fix tests and other fixes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07* ext/json: Merge JSON 1.7.1.naruse
https://github.com/flori/json/commit/e5b9a9465c1159fae533bca320d950b772bcb4ac git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-11* ext/json: Merge 164a75c8bd2007d32c4d7665d53140d8fc126dcd.naruse
[ruby-core:41917] [Bug #5846] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-30* ext/json: Merge json gem 1.5.4+ (2149f4185c598fb97db1).naruse
[Bug #5173] [ruby-core:38866] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10* ext/json: Merge json gem 1.5.4+ (f7f78896607b6f6226cd).naruse
[Bug #4700] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-06* ext/json/lib/json/common.rb (JSON::MissingUnicodeSupport.iconv):nobu
should not drop rest of the result. use Iconv.conv instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-01* ext/json/lib/json/common.rb: don't use iconv on 1.9.naruse
patched by Shota Fukumori [ruby-core:33164] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-01* ext/json: Update github/flori/json from 1.4.2+ tonaruse
e22b2f2bdfe6a9b0. this fixes some bugs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-26Recommit of JSON; fix mixed declarations.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-26* ext/jason: revert r27493. came again after canceling gcc-ism.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e