Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NEWS for Ruby 3.5.0
# NEWS for Ruby 4.0.0

This document is a list of user-visible feature changes
since the **3.4.0** release, except for bug fixes.
Expand Down Expand Up @@ -192,7 +192,7 @@ The following default gems are updated.
* io-console 0.8.1
* io-nonblock 0.3.2
* io-wait 0.3.3
* json 2.15.2
* json 2.16.0
* net-http 0.7.0
* openssl 4.0.0.pre
* optparse 0.8.0
Expand Down
19 changes: 7 additions & 12 deletions ext/json/lib/json/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ def create_additions_proc(opts)
end
when object_class
if opts[:create_additions] != false
if class_name = object[JSON.create_id]
klass = JSON.deep_const_get(class_name)
if class_path = object[JSON.create_id]
klass = begin
Object.const_get(class_path)
rescue NameError => e
raise ArgumentError, "can't get const #{class_path}: #{e}"
end

if klass.respond_to?(:json_creatable?) ? klass.json_creatable? : klass.respond_to?(:json_create)
create_additions_warning if create_additions.nil?
object = klass.json_create(object)
Expand Down Expand Up @@ -147,16 +152,6 @@ def parser=(parser) # :nodoc:
const_set :Parser, parser
end

# Return the constant located at _path_. The format of _path_ has to be
# either ::A::B::C or A::B::C. In any case, A has to be located at the top
# level (absolute namespace path?). If there doesn't exist a constant at
# the given path, an ArgumentError is raised.
def deep_const_get(path) # :nodoc:
Object.const_get(path)
rescue NameError => e
raise ArgumentError, "can't get const #{path}: #{e}"
end

# Set the module _generator_ to be used by JSON.
def generator=(generator) # :nodoc:
old, $VERBOSE = $VERBOSE, nil
Expand Down
4 changes: 4 additions & 0 deletions ext/json/lib/json/ext/generator/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def to_h
#
# Returns the value returned by method +name+.
def [](name)
::JSON.deprecation_warning("JSON::State#[] is deprecated and will be removed in json 3.0.0")

if respond_to?(name)
__send__(name)
else
Expand All @@ -87,6 +89,8 @@ def [](name)
#
# Sets the attribute name to value.
def []=(name, value)
::JSON.deprecation_warning("JSON::State#[]= is deprecated and will be removed in json 3.0.0")

if respond_to?(name_writer = "#{name}=")
__send__ name_writer, value
else
Expand Down
2 changes: 1 addition & 1 deletion ext/json/lib/json/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JSON
VERSION = '2.15.2'
VERSION = '2.16.0'
end
90 changes: 0 additions & 90 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -6494,96 +6494,6 @@ rb_is_absolute_path(const char *path)
return 0;
}

#ifndef ENABLE_PATH_CHECK
# if defined DOSISH || defined __CYGWIN__
# define ENABLE_PATH_CHECK 0
# else
# define ENABLE_PATH_CHECK 1
# endif
#endif

#if ENABLE_PATH_CHECK
static int
path_check_0(VALUE path)
{
struct stat st;
const char *p0 = StringValueCStr(path);
const char *e0;
rb_encoding *enc;
char *p = 0, *s;

if (!rb_is_absolute_path(p0)) {
char *buf = ruby_getcwd();
VALUE newpath;

newpath = rb_str_new2(buf);
xfree(buf);

rb_str_cat2(newpath, "/");
rb_str_cat2(newpath, p0);
path = newpath;
p0 = RSTRING_PTR(path);
}
e0 = p0 + RSTRING_LEN(path);
enc = rb_enc_get(path);
for (;;) {
#ifndef S_IWOTH
# define S_IWOTH 002
#endif
if (STAT(p0, &st) == 0 && S_ISDIR(st.st_mode) && (st.st_mode & S_IWOTH)
#ifdef S_ISVTX
&& !(p && (st.st_mode & S_ISVTX))
#endif
&& !access(p0, W_OK)) {
rb_enc_warn(enc, "Insecure world writable dir %s in PATH, mode 0%"
#if SIZEOF_DEV_T > SIZEOF_INT
PRI_MODET_PREFIX"o",
#else
"o",
#endif
p0, st.st_mode);
if (p) *p = '/';
RB_GC_GUARD(path);
return 0;
}
s = strrdirsep(p0, e0, enc);
if (p) *p = '/';
if (!s || s == p0) return 1;
p = s;
e0 = p;
*p = '\0';
}
}
#endif

int
rb_path_check(const char *path)
{
rb_warn_deprecated_to_remove_at(3.6, "rb_path_check", NULL);
#if ENABLE_PATH_CHECK
const char *p0, *p, *pend;
const char sep = PATH_SEP_CHAR;

if (!path) return 1;

pend = path + strlen(path);
p0 = path;
p = strchr(path, sep);
if (!p) p = pend;

for (;;) {
if (!path_check_0(rb_str_new(p0, p - p0))) {
return 0; /* not safe */
}
p0 = p + 1;
if (p0 > pend) break;
p = strchr(p0, sep);
if (!p) p = pend;
}
#endif
return 1;
}

int
ruby_is_fd_loadable(int fd)
{
Expand Down
2 changes: 1 addition & 1 deletion include/ruby/internal/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* In released versions of Ruby, this number is not defined since teeny
* versions of Ruby should guarantee ABI compatibility.
*/
#define RUBY_ABI_VERSION 4
#define RUBY_ABI_VERSION 0

/* Windows does not support weak symbols so ruby_abi_version will not exist
* in the shared library. */
Expand Down
4 changes: 2 additions & 2 deletions include/ruby/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
* doesn't mean a total rewrite. Practically when it comes to API versioning,
* major and minor version changes are equally catastrophic.
*/
#define RUBY_API_VERSION_MAJOR 3
#define RUBY_API_VERSION_MAJOR 4

/**
* Minor version. As of writing this version changes annually. Greater
* version doesn't mean "better"; they just mean years passed.
*/
#define RUBY_API_VERSION_MINOR 5
#define RUBY_API_VERSION_MINOR 0

/**
* Teeny version. This digit is kind of reserved these days. Kept 0 for the
Expand Down
35 changes: 3 additions & 32 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -8223,21 +8223,6 @@ rb_io_s_sysopen(int argc, VALUE *argv, VALUE _)
return INT2NUM(fd);
}

static VALUE
check_pipe_command(VALUE filename_or_command)
{
char *s = RSTRING_PTR(filename_or_command);
long l = RSTRING_LEN(filename_or_command);
char *e = s + l;
int chlen;

if (rb_enc_ascget(s, e, &chlen, rb_enc_get(filename_or_command)) == '|') {
VALUE cmd = rb_str_new(s+chlen, l-chlen);
return cmd;
}
return Qnil;
}

/*
* call-seq:
* open(path, mode = 'r', perm = 0666, **opts) -> io or nil
Expand Down Expand Up @@ -8283,13 +8268,7 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
redirect = TRUE;
}
else {
VALUE cmd = check_pipe_command(tmp);
if (!NIL_P(cmd)) {
// TODO: when removed in 4.0, update command_injection.rdoc
rb_warn_deprecated_to_remove_at(4.0, "Calling Kernel#open with a leading '|'", "IO.popen");
argv[0] = cmd;
return rb_io_s_popen(argc, argv, rb_cIO);
}
argv[0] = tmp;
}
}
}
Expand All @@ -8308,16 +8287,8 @@ static VALUE
rb_io_open_generic(VALUE klass, VALUE filename, int oflags, enum rb_io_mode fmode,
const struct rb_io_encoding *convconfig, mode_t perm)
{
VALUE cmd;
if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
// TODO: when removed in 4.0, update command_injection.rdoc
rb_warn_deprecated_to_remove_at(4.0, "IO process creation with a leading '|'", "IO.popen");
return pipe_open_s(cmd, rb_io_oflags_modestr(oflags), fmode, convconfig);
}
else {
return rb_file_open_generic(io_alloc(klass), filename,
oflags, fmode, convconfig, perm);
}
return rb_file_open_generic(io_alloc(klass), filename,
oflags, fmode, convconfig, perm);
}

static VALUE
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/current_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.current_ruby
end

class CurrentRuby
ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze
ALL_RUBY_VERSIONS = [*18..27, *30..34, *40].freeze
KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze
KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze
PLATFORM_MAP = {
Expand Down
2 changes: 2 additions & 0 deletions lib/prism/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ def dump_options_version(version)
2
when /\A3\.5(\.\d+)?\z/
3
when /\A4\.0(\.\d+)?\z/
4
else
if current
raise CurrentVersionError, RUBY_VERSION
Expand Down
10 changes: 10 additions & 0 deletions prism/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
return true;
}

if (strncmp(version, "4.0", 3) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
return true;
}

return false;
}

Expand All @@ -111,6 +116,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
options->version = PM_OPTIONS_VERSION_CRUBY_3_5;
return true;
}

if (strncmp(version, "4.0.", 4) == 0 && is_number(version + 4, length - 4)) {
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
return true;
}
}

if (length >= 6) {
Expand Down
5 changes: 4 additions & 1 deletion prism/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ typedef enum {
/** The vendored version of prism in CRuby 3.5.x. */
PM_OPTIONS_VERSION_CRUBY_3_5 = 3,

/** The vendored version of prism in CRuby 4.0.x. */
PM_OPTIONS_VERSION_CRUBY_4_0 = 4,

/** The current version of prism. */
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_3_5
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_0
} pm_options_version_t;

/**
Expand Down
14 changes: 7 additions & 7 deletions spec/bundler/bundler/current_ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ruby_32: Gem::Platform::RUBY,
ruby_33: Gem::Platform::RUBY,
ruby_34: Gem::Platform::RUBY,
ruby_35: Gem::Platform::RUBY,
ruby_40: Gem::Platform::RUBY,
mri: Gem::Platform::RUBY,
mri_18: Gem::Platform::RUBY,
mri_19: Gem::Platform::RUBY,
Expand All @@ -39,7 +39,7 @@
mri_32: Gem::Platform::RUBY,
mri_33: Gem::Platform::RUBY,
mri_34: Gem::Platform::RUBY,
mri_35: Gem::Platform::RUBY,
mri_40: Gem::Platform::RUBY,
rbx: Gem::Platform::RUBY,
truffleruby: Gem::Platform::RUBY,
jruby: Gem::Platform::JAVA,
Expand All @@ -61,7 +61,7 @@
windows_32: Gem::Platform::WINDOWS,
windows_33: Gem::Platform::WINDOWS,
windows_34: Gem::Platform::WINDOWS,
windows_35: Gem::Platform::WINDOWS }
windows_40: Gem::Platform::WINDOWS }
end

let(:deprecated) do
Expand All @@ -81,7 +81,7 @@
mswin_32: Gem::Platform::MSWIN,
mswin_33: Gem::Platform::MSWIN,
mswin_34: Gem::Platform::MSWIN,
mswin_35: Gem::Platform::MSWIN,
mswin_40: Gem::Platform::MSWIN,
mswin64: Gem::Platform::MSWIN64,
mswin64_19: Gem::Platform::MSWIN64,
mswin64_20: Gem::Platform::MSWIN64,
Expand All @@ -97,7 +97,7 @@
mswin64_32: Gem::Platform::MSWIN64,
mswin64_33: Gem::Platform::MSWIN64,
mswin64_34: Gem::Platform::MSWIN64,
mswin64_35: Gem::Platform::MSWIN64,
mswin64_40: Gem::Platform::MSWIN64,
mingw: Gem::Platform::UNIVERSAL_MINGW,
mingw_18: Gem::Platform::UNIVERSAL_MINGW,
mingw_19: Gem::Platform::UNIVERSAL_MINGW,
Expand All @@ -114,7 +114,7 @@
mingw_32: Gem::Platform::UNIVERSAL_MINGW,
mingw_33: Gem::Platform::UNIVERSAL_MINGW,
mingw_34: Gem::Platform::UNIVERSAL_MINGW,
mingw_35: Gem::Platform::UNIVERSAL_MINGW,
mingw_40: Gem::Platform::UNIVERSAL_MINGW,
x64_mingw: Gem::Platform::UNIVERSAL_MINGW,
x64_mingw_20: Gem::Platform::UNIVERSAL_MINGW,
x64_mingw_21: Gem::Platform::UNIVERSAL_MINGW,
Expand All @@ -129,7 +129,7 @@
x64_mingw_32: Gem::Platform::UNIVERSAL_MINGW,
x64_mingw_33: Gem::Platform::UNIVERSAL_MINGW,
x64_mingw_34: Gem::Platform::UNIVERSAL_MINGW,
x64_mingw_35: Gem::Platform::UNIVERSAL_MINGW }
x64_mingw_40: Gem::Platform::UNIVERSAL_MINGW }
end
# rubocop:enable Naming/VariableNumber

Expand Down
4 changes: 2 additions & 2 deletions spec/bundler/bundler/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@
describe "#gem" do
# rubocop:disable Naming/VariableNumber
[:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :ruby_27,
:ruby_30, :ruby_31, :ruby_32, :ruby_33, :ruby_34, :ruby_35, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24,
:mri_25, :mri_26, :mri_27, :mri_30, :mri_31, :mri_32, :mri_33, :mri_34, :mri_35, :jruby, :rbx, :truffleruby].each do |platform|
:ruby_30, :ruby_31, :ruby_32, :ruby_33, :ruby_34, :ruby_40, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24,
:mri_25, :mri_26, :mri_27, :mri_30, :mri_31, :mri_32, :mri_33, :mri_34, :mri_40, :jruby, :rbx, :truffleruby].each do |platform|
it "allows #{platform} as a valid platform" do
subject.gem("foo", platform: platform)
end
Expand Down
5 changes: 0 additions & 5 deletions test/json/json_common_interface_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ def test_create_id
JSON.create_id = 'json_class'
end

def test_deep_const_get
assert_raise(ArgumentError) { JSON.deep_const_get('Nix::Da') }
assert_equal File::SEPARATOR, JSON.deep_const_get('File::SEPARATOR')
end

def test_parse
assert_equal [ 1, 2, 3, ], JSON.parse('[ 1, 2, 3 ]')
end
Expand Down
Loading