Skip to content

Commit

Permalink
Fix broken DTD name handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cfis committed Jan 8, 2024
1 parent e38d3b0 commit 2852b92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions ext/libxml/ruby_xml_dtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ static VALUE rxml_dtd_type(VALUE self)
*
* * The first usage creates a DTD from a string and requires 1 parameter.
* * The second usage loads and parses an external DTD and requires 2 parameters.
* * The third usage creates a new internal or external DTD and requires 3 parameters and 2 optional parameters.
* It then attaches the DTD to the specified document if it is not nil
* * The third usage creates a new internal or external DTD and requires 2 parameters and 3 optional parameters.
* The DTD is then attached to the specified document if it is not nil.
*
* Parameters:
*
Expand All @@ -160,16 +160,19 @@ static VALUE rxml_dtd_initialize(int argc, VALUE *argv, VALUE self)
xmlDocPtr xdoc = NULL;

VALUE name, doc, internal;
rb_scan_args(argc, argv, "32", &external, &system, &name, &doc, &internal);
rb_scan_args(argc, argv, "23", &external, &system, &name, &doc, &internal);

Check_Type(external, T_STRING);
xpublic = (const xmlChar*) StringValuePtr(external);

Check_Type(system, T_STRING);
xsystem = (const xmlChar*) StringValuePtr(system);

Check_Type(name, T_STRING);
xname = (const xmlChar*) StringValuePtr(name);
if (name != Qnil)
{
Check_Type(name, T_STRING);
xname = (const xmlChar*)StringValuePtr(name);
}

if (doc != Qnil)
{
Expand Down
2 changes: 1 addition & 1 deletion test/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_doc_node_type_name
def test_xhtml
doc = LibXML::XML::Document.new
assert(!doc.xhtml?)
LibXML::XML::Dtd.new "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", nil, doc, true
LibXML::XML::Dtd.new("-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", nil, doc, true)
assert(doc.xhtml?)
end

Expand Down

0 comments on commit 2852b92

Please sign in to comment.