mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Remove tainted and trusted features
Already these had been announced to be removed in 3.2.
This commit is contained in:
parent
81c248924d
commit
39bc5de833
Notes:
git
2021-12-27 00:34:23 +09:00
14 changed files with 12 additions and 308 deletions
13
error.c
13
error.c
|
@ -3392,19 +3392,6 @@ rb_check_frozen(VALUE obj)
|
|||
rb_check_frozen_internal(obj);
|
||||
}
|
||||
|
||||
void
|
||||
rb_error_untrusted(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "rb_error_untrusted", NULL);
|
||||
}
|
||||
|
||||
#undef rb_check_trusted
|
||||
void
|
||||
rb_check_trusted(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "rb_check_trusted", NULL);
|
||||
}
|
||||
|
||||
void
|
||||
rb_check_copyable(VALUE obj, VALUE orig)
|
||||
{
|
||||
|
|
7
hash.c
7
hash.c
|
@ -5043,13 +5043,6 @@ env_fetch(int argc, VALUE *argv, VALUE _)
|
|||
return env;
|
||||
}
|
||||
|
||||
int
|
||||
rb_env_path_tainted(void)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "rb_env_path_tainted", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
|
||||
#elif defined __sun
|
||||
static int
|
||||
|
|
|
@ -450,12 +450,6 @@ enum {
|
|||
#undef RBIMPL_HAVE_ENUM_ATTRIBUTE
|
||||
|
||||
RBIMPL_SYMBOL_EXPORT_BEGIN()
|
||||
/**
|
||||
* @deprecated Does nothing. This method is deprecated and will be removed in
|
||||
* Ruby 3.2.
|
||||
*/
|
||||
void rb_obj_infect(VALUE victim, VALUE carrier);
|
||||
|
||||
/**
|
||||
* This is an implementation detail of #RB_OBJ_FREEZE(). People don't use it
|
||||
* directly.
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
#define rb_exc_new3 rb_exc_new_str /**< @old{rb_exc_new_str} */
|
||||
|
||||
/** @cond INTERNAL_MACRO */
|
||||
#define rb_check_trusted rb_check_trusted
|
||||
#define rb_check_trusted_inline rb_check_trusted
|
||||
#define rb_check_arity rb_check_arity
|
||||
/** @endcond */
|
||||
|
||||
|
|
|
@ -287,15 +287,6 @@ int rb_path_check(const char *path);
|
|||
|
||||
/* hash.c */
|
||||
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @return 0 always.
|
||||
*/
|
||||
int rb_env_path_tainted(void);
|
||||
|
||||
/**
|
||||
* Destructively removes every environment variables of the running process.
|
||||
*
|
||||
|
|
|
@ -202,74 +202,6 @@ VALUE rb_obj_dup(VALUE obj);
|
|||
*/
|
||||
VALUE rb_obj_init_copy(VALUE src, VALUE dst);
|
||||
|
||||
RBIMPL_ATTR_DEPRECATED_EXT(("taintedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] obj Object in question.
|
||||
* @return Verbatim `obj`.
|
||||
*/
|
||||
VALUE rb_obj_taint(VALUE obj);
|
||||
|
||||
RBIMPL_ATTR_PURE()
|
||||
RBIMPL_ATTR_DEPRECATED_EXT(("taintedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] obj Object in question.
|
||||
* @return Always returns ::RUBY_Qfalse.
|
||||
*/
|
||||
VALUE rb_obj_tainted(VALUE obj);
|
||||
|
||||
RBIMPL_ATTR_DEPRECATED_EXT(("taintedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] obj Object in question.
|
||||
* @return Verbatim `obj`.
|
||||
*/
|
||||
VALUE rb_obj_untaint(VALUE obj);
|
||||
|
||||
RBIMPL_ATTR_DEPRECATED_EXT(("trustedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] obj Object in question.
|
||||
* @return Verbatim `obj`.
|
||||
*/
|
||||
VALUE rb_obj_untrust(VALUE obj);
|
||||
|
||||
RBIMPL_ATTR_PURE()
|
||||
RBIMPL_ATTR_DEPRECATED_EXT(("trustedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] obj Object in question.
|
||||
* @return Always returns ::RUBY_Qfalse.
|
||||
*/
|
||||
VALUE rb_obj_untrusted(VALUE obj);
|
||||
|
||||
RBIMPL_ATTR_DEPRECATED_EXT(("trustedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] obj Object in question.
|
||||
* @return Verbatim `obj`.
|
||||
*/
|
||||
VALUE rb_obj_trust(VALUE obj);
|
||||
|
||||
/**
|
||||
* Just calls rb_obj_freeze_inline() inside. Does this make any sens to
|
||||
* extension libraries?
|
||||
|
|
|
@ -122,37 +122,6 @@ VALUE rb_str_new_frozen(VALUE str);
|
|||
*/
|
||||
VALUE rb_str_new_with_class(VALUE obj, const char *ptr, long len);
|
||||
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] ptr A C string.
|
||||
* @exception rb_eNoMemError Failed to allocate memory.
|
||||
* @exception rb_eArgError `ptr` is a null pointer.
|
||||
* @return An instance of ::rb_cString, of "binary" encoding, whose
|
||||
* contents are verbatim copy of `ptr`.
|
||||
* @pre `ptr` must not be a null pointer.
|
||||
*/
|
||||
VALUE rb_tainted_str_new_cstr(const char *ptr);
|
||||
|
||||
/**
|
||||
* @deprecated This function once was a thing in the old days, but makes no
|
||||
* sense any longer today. Exists here for backwards
|
||||
* compatibility only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] ptr A memory region of `len` bytes length.
|
||||
* @param[in] len Length of `ptr`, in bytes, not including the
|
||||
* terminating NUL character.
|
||||
* @exception rb_eNoMemError Failed to allocate `len+1` bytes.
|
||||
* @exception rb_eArgError `len` is negative.
|
||||
* @return An instance of ::rb_cString, of `len` bytes length, of
|
||||
* "binary" encoding, whose contents are verbatim copy of `ptr`.
|
||||
* @pre At least `len` bytes of continuous memory region shall be
|
||||
* accessible via `ptr`.
|
||||
*/
|
||||
VALUE rb_tainted_str_new(const char *ptr, long len);
|
||||
|
||||
/**
|
||||
* Identical to rb_str_new(), except it generates a string of "default
|
||||
* external" encoding.
|
||||
|
@ -1398,22 +1367,6 @@ rbimpl_str_new_cstr(const char *str)
|
|||
return rb_str_new_static(str, len);
|
||||
}
|
||||
|
||||
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* This is an implementation detail. Don't bother.
|
||||
*
|
||||
* @param[in] str A C string literal.
|
||||
* @return Corresponding Ruby string.
|
||||
*/
|
||||
static inline VALUE
|
||||
rbimpl_tainted_str_new_cstr(const char *str)
|
||||
{
|
||||
long len = rbimpl_strlen(str);
|
||||
return rb_tainted_str_new(str, len);
|
||||
}
|
||||
|
||||
RBIMPL_ATTR_NONNULL(())
|
||||
/**
|
||||
* @private
|
||||
|
@ -1599,22 +1552,6 @@ rbimpl_exc_new_cstr(VALUE exc, const char *str)
|
|||
rb_utf8_str_new_static : \
|
||||
rb_utf8_str_new) ((str), (len)))
|
||||
|
||||
/**
|
||||
* @deprecated This macro once was a thing in the old days, but makes no sense
|
||||
* any longer today. Exists here for backwards compatibility
|
||||
* only. You can safely forget about it.
|
||||
*
|
||||
* @param[in] str A C string.
|
||||
* @exception rb_eNoMemError Failed to allocate memory.
|
||||
* @return An instance of ::rb_cString, of "binary" encoding, whose
|
||||
* contents are verbatim copy of `str`.
|
||||
* @pre `str` must not be a null pointer.
|
||||
*/
|
||||
#define rb_tainted_str_new_cstr(str) \
|
||||
((RBIMPL_CONSTANT_P(str) ? \
|
||||
rbimpl_tainted_str_new_cstr : \
|
||||
rb_tainted_str_new_cstr) (str))
|
||||
|
||||
/**
|
||||
* Identical to #rb_str_new_cstr, except it generates a string of "US ASCII"
|
||||
* encoding. It can also be seen as a routine Identical to
|
||||
|
@ -1739,7 +1676,6 @@ rbimpl_exc_new_cstr(VALUE exc, const char *str)
|
|||
#define rb_str_new3 rb_str_new_shared /**< @old{rb_str_new_shared} */
|
||||
#define rb_str_new4 rb_str_new_frozen /**< @old{rb_str_new_frozen} */
|
||||
#define rb_str_new5 rb_str_new_with_class /**< @old{rb_str_new_with_class} */
|
||||
#define rb_tainted_str_new2 rb_tainted_str_new_cstr /**< @old{rb_tainted_str_new_cstr} */
|
||||
#define rb_str_buf_new2 rb_str_buf_new_cstr /**< @old{rb_str_buf_new_cstr} */
|
||||
#define rb_usascii_str_new2 rb_usascii_str_new_cstr /**< @old{rb_usascii_str_new_cstr} */
|
||||
#define rb_str_buf_cat rb_str_cat /**< @alias{rb_str_cat} */
|
||||
|
|
98
object.c
98
object.c
|
@ -1100,98 +1100,6 @@ rb_obj_dummy1(VALUE _x, VALUE _y)
|
|||
return rb_obj_dummy();
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.tainted? -> false
|
||||
*
|
||||
* Returns false. This method is deprecated and will be removed in Ruby 3.2.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_obj_tainted(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "Object#tainted?", NULL);
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.taint -> obj
|
||||
*
|
||||
* Returns object. This method is deprecated and will be removed in Ruby 3.2.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_obj_taint(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "Object#taint", NULL);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.untaint -> obj
|
||||
*
|
||||
* Returns object. This method is deprecated and will be removed in Ruby 3.2.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_obj_untaint(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "Object#untaint", NULL);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.untrusted? -> false
|
||||
*
|
||||
* Returns false. This method is deprecated and will be removed in Ruby 3.2.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_obj_untrusted(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "Object#untrusted?", NULL);
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.untrust -> obj
|
||||
*
|
||||
* Returns object. This method is deprecated and will be removed in Ruby 3.2.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_obj_untrust(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "Object#untrust", NULL);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.trust -> obj
|
||||
*
|
||||
* Returns object. This method is deprecated and will be removed in Ruby 3.2.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_obj_trust(VALUE obj)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "Object#trust", NULL);
|
||||
return obj;
|
||||
}
|
||||
|
||||
void
|
||||
rb_obj_infect(VALUE victim, VALUE carrier)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "rb_obj_infect", NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.freeze -> obj
|
||||
|
@ -4549,12 +4457,6 @@ InitVM_Object(void)
|
|||
rb_define_method(rb_mKernel, "initialize_dup", rb_obj_init_dup_clone, 1);
|
||||
rb_define_method(rb_mKernel, "initialize_clone", rb_obj_init_clone, -1);
|
||||
|
||||
rb_define_method(rb_mKernel, "taint", rb_obj_taint, 0);
|
||||
rb_define_method(rb_mKernel, "tainted?", rb_obj_tainted, 0);
|
||||
rb_define_method(rb_mKernel, "untaint", rb_obj_untaint, 0);
|
||||
rb_define_method(rb_mKernel, "untrust", rb_obj_untrust, 0);
|
||||
rb_define_method(rb_mKernel, "untrusted?", rb_obj_untrusted, 0);
|
||||
rb_define_method(rb_mKernel, "trust", rb_obj_trust, 0);
|
||||
rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0);
|
||||
|
||||
rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0);
|
||||
|
|
|
@ -161,9 +161,11 @@ static VALUE object_specs_rb_obj_method(VALUE self, VALUE obj, VALUE method) {
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef RUBY_VERSION_IS_3_2
|
||||
static VALUE object_spec_rb_obj_taint(VALUE self, VALUE obj) {
|
||||
return rb_obj_taint(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
# pragma GCC diagnostic pop
|
||||
|
@ -448,7 +450,9 @@ void Init_object_spec(void) {
|
|||
rb_define_method(cls, "rb_obj_is_kind_of", so_kind_of, 2);
|
||||
rb_define_method(cls, "rb_obj_method_arity", object_specs_rb_obj_method_arity, 2);
|
||||
rb_define_method(cls, "rb_obj_method", object_specs_rb_obj_method, 2);
|
||||
#ifndef RUBY_VERSION_IS_3_2
|
||||
rb_define_method(cls, "rb_obj_taint", object_spec_rb_obj_taint, 1);
|
||||
#endif
|
||||
rb_define_method(cls, "rb_require", so_require, 0);
|
||||
rb_define_method(cls, "rb_respond_to", so_respond_to, 2);
|
||||
rb_define_method(cls, "rb_method_boundp", object_spec_rb_method_boundp, 3);
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
(RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR < (minor)) || \
|
||||
(RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR == (minor) && RUBY_VERSION_TEENY < (teeny)))
|
||||
|
||||
#if RUBY_VERSION_MAJOR > 3 || (RUBY_VERSION_MAJOR == 3 && RUBY_VERSION_MINOR >= 2)
|
||||
#define RUBY_VERSION_IS_3_2
|
||||
#endif
|
||||
|
||||
#if RUBY_VERSION_MAJOR > 3 || (RUBY_VERSION_MAJOR == 3 && RUBY_VERSION_MINOR >= 1)
|
||||
#define RUBY_VERSION_IS_3_1
|
||||
#endif
|
||||
|
|
|
@ -261,6 +261,7 @@ VALUE string_spec_rb_str_new5(VALUE self, VALUE str, VALUE ptr, VALUE len) {
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef RUBY_VERSION_IS_3_2
|
||||
VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) {
|
||||
return rb_tainted_str_new(RSTRING_PTR(str), FIX2INT(len));
|
||||
}
|
||||
|
@ -268,6 +269,7 @@ VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) {
|
|||
VALUE string_spec_rb_tainted_str_new2(VALUE self, VALUE str) {
|
||||
return rb_tainted_str_new2(RSTRING_PTR(str));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
# pragma GCC diagnostic pop
|
||||
|
@ -629,8 +631,10 @@ void Init_string_spec(void) {
|
|||
rb_define_method(cls, "rb_str_new3", string_spec_rb_str_new3, 1);
|
||||
rb_define_method(cls, "rb_str_new4", string_spec_rb_str_new4, 1);
|
||||
rb_define_method(cls, "rb_str_new5", string_spec_rb_str_new5, 3);
|
||||
#ifndef RUBY_VERSION_IS_3_2
|
||||
rb_define_method(cls, "rb_tainted_str_new", string_spec_rb_tainted_str_new, 2);
|
||||
rb_define_method(cls, "rb_tainted_str_new2", string_spec_rb_tainted_str_new2, 1);
|
||||
#endif
|
||||
rb_define_method(cls, "rb_str_plus", string_spec_rb_str_plus, 2);
|
||||
rb_define_method(cls, "rb_str_times", string_spec_rb_str_times, 2);
|
||||
rb_define_method(cls, "rb_str_modify_expand", string_spec_rb_str_modify_expand, 2);
|
||||
|
|
15
string.c
15
string.c
|
@ -63,7 +63,6 @@
|
|||
#undef rb_utf8_str_new
|
||||
#undef rb_enc_str_new
|
||||
#undef rb_str_new_cstr
|
||||
#undef rb_tainted_str_new_cstr
|
||||
#undef rb_usascii_str_new_cstr
|
||||
#undef rb_utf8_str_new_cstr
|
||||
#undef rb_enc_str_new_cstr
|
||||
|
@ -1036,20 +1035,6 @@ rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc)
|
|||
return str_new_static(rb_cString, ptr, len, rb_enc_to_index(enc));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_tainted_str_new(const char *ptr, long len)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "rb_tainted_str_new", NULL);
|
||||
return rb_str_new(ptr, len);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_tainted_str_new_cstr(const char *ptr)
|
||||
{
|
||||
rb_warn_deprecated_to_remove_at(3.2, "rb_tainted_str_new_cstr", NULL);
|
||||
return rb_str_new_cstr(ptr);
|
||||
}
|
||||
|
||||
static VALUE str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
|
||||
rb_encoding *from, rb_encoding *to,
|
||||
int ecflags, VALUE ecopts);
|
||||
|
|
|
@ -57,18 +57,4 @@ class Test_String_Fstring < Test::Unit::TestCase
|
|||
str.freeze
|
||||
assert_fstring(str) {|s| assert_instance_of(S, s)}
|
||||
end
|
||||
|
||||
def test_shared_string_safety
|
||||
_unused = -('a' * 30).force_encoding(Encoding::ASCII)
|
||||
begin
|
||||
verbose_back, $VERBOSE = $VERBOSE, nil
|
||||
str = ('a' * 30).force_encoding(Encoding::ASCII).taint
|
||||
ensure
|
||||
$VERBOSE = verbose_back
|
||||
end
|
||||
frozen_str = Bug::String.rb_str_new_frozen(str)
|
||||
assert_fstring(frozen_str) {|s| assert_equal(str, s)}
|
||||
GC.start
|
||||
assert_equal('a' * 30, str, "[Bug #16151]")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1075,18 +1075,6 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
assert_equal :deprecated, warning[0][1]
|
||||
end
|
||||
|
||||
def test_warn_deprecated_to_remove_backwards_compatibility_category
|
||||
warning = capture_warning_warn { Object.new.tainted? }
|
||||
|
||||
assert_match(/deprecated/, warning[0])
|
||||
end
|
||||
|
||||
def test_warn_deprecated_to_remove_category
|
||||
warning = capture_warning_warn(category: true) { Object.new.tainted? }
|
||||
|
||||
assert_equal :deprecated, warning[0][1]
|
||||
end
|
||||
|
||||
def test_kernel_warn_uplevel
|
||||
warning = capture_warning_warn {warn("test warning", uplevel: 0)}
|
||||
assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0])
|
||||
|
|
Loading…
Add table
Reference in a new issue