Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the default allocator function from Document #2242

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/nokogiri/xml_document.c
Expand Up @@ -663,6 +663,8 @@ noko_init_xml_document()
*/
cNokogiriXmlDocument = rb_define_class_under(mNokogiriXml, "Document", cNokogiriXmlNode);

rb_undef_alloc_func(cNokogiriXmlDocument);

rb_define_singleton_method(cNokogiriXmlDocument, "read_memory", read_memory, 4);
rb_define_singleton_method(cNokogiriXmlDocument, "read_io", read_io, 4);
rb_define_singleton_method(cNokogiriXmlDocument, "new", new, -1);
Expand Down
6 changes: 6 additions & 0 deletions test/xml/test_document.rb
Expand Up @@ -15,6 +15,12 @@ class TestDocument < Nokogiri::TestCase

let(:xml) { Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) }

def test_allocation_is_not_allowed
assert_raises(TypeError) do
Nokogiri::XML::Document.allocate
end
end

def test_dtd_with_empty_internal_subset
doc = Nokogiri::XML(<<~eoxml)
<?xml version="1.0"?>
Expand Down