Skip to content

[bug] DTD#attributes should not be a hash, it should be an array #2995

@flavorjones

Description

@flavorjones

Please describe the bug

Since 35cace6 in 2008, DTD#attributes has returned a Hash<String => AttributeDecl> where the key is the attribute name.

This doesn't make any sense, since the attribute name does not need to be unique, for example:

doc = Nokogiri::XML::Document.parse(<<~XML)
  <?xml version="1.0"?>
  <!DOCTYPE staff SYSTEM "foo.dtd" [
     <!ATTLIST br width CDATA "0">
     <!ATTLIST a width CDATA "0">
  ]>
  <root />
XML

doc.internal_subset.attributes
# => {"width"=>#(AttributeDecl:0x43f8 { "<!ATTLIST br width CDATA \"0\">\n" })}

This should probably just be an array, and not a hash. And in that case, DTD should not be Enumerable and we should remove the #each method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions