[flori/json] Call super
in included
hook
The C extension defines an `included` hook for the `JSON::Ext::Generator::GeneratorMethods::String` module but neglects to call `super` in the hook. This can break the functionality of various other code that rely on the fact that `included` on `Module` will always be called. https://github.com/flori/json/commit/cd8bbe56a3
This commit is contained in:
parent
28056a6d16
commit
12dfd9d1c9
@ -478,6 +478,7 @@ static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
|
|||||||
*/
|
*/
|
||||||
static VALUE mString_included_s(VALUE self, VALUE modul) {
|
static VALUE mString_included_s(VALUE self, VALUE modul) {
|
||||||
VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
|
VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
|
||||||
|
rb_call_super(1, &modul);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +391,29 @@ EOT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if defined?(JSON::Ext::Generator)
|
||||||
|
def test_string_ext_included_calls_super
|
||||||
|
included = false
|
||||||
|
|
||||||
|
Module.alias_method(:included_orig, :included)
|
||||||
|
Module.define_method(:included) do |base|
|
||||||
|
included_orig(base)
|
||||||
|
included = true
|
||||||
|
end
|
||||||
|
|
||||||
|
Class.new(String) do
|
||||||
|
include JSON::Ext::Generator::GeneratorMethods::String
|
||||||
|
end
|
||||||
|
|
||||||
|
assert included
|
||||||
|
ensure
|
||||||
|
if Module.private_method_defined?(:included_orig)
|
||||||
|
Module.alias_method(:included, :included_orig)
|
||||||
|
Module.remove_method(:included_orig)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if defined?(Encoding)
|
if defined?(Encoding)
|
||||||
def test_nonutf8_encoding
|
def test_nonutf8_encoding
|
||||||
assert_equal("\"5\u{b0}\"", "5\xb0".force_encoding("iso-8859-1").to_json)
|
assert_equal("\"5\u{b0}\"", "5\xb0".force_encoding("iso-8859-1").to_json)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user