Subject: [xml2rfc] #268 (Version 2 cli): Crash with <reference> that has no anchor attribute

From: "xml2rfc issue tracker" <[email-masked]>
Date: Thu, 10 Jul 2014 18:12:24 -0000

#268: Crash with <reference> that has no anchor attribute

 The intention (c.f., draft-reschke-xml2rfc-09) is apparently that the
 anchor attribute of <reference> elements is now mandatory.  As of v2.4.6
 (svn r1450),
 the DTD used by xml2rfc (trunk/cli/xml2rfc/templates/rfc2929.dtd) has:
 <!ELEMENT reference   (front,seriesInfo*,format*,annotation*)>
 <!ATTLIST reference
           anchor      ID                 #IMPLIED
           target      %URI;              #IMPLIED>
 making the anchor optional.

 Accordingly parsing a xml2rfc source with a reference that has no anchor
 attribute does not trigger an XML parsing error, but it crashes later with
 the following traceback (from the online version):
 Traceback (most recent call last):
   File "/usr/local/bin/xml2rfc", line 5, in <module>
     pkg_resources.run_script('xml2rfc==2.4.9dev0', 'xml2rfc')
   File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line
 534, in run_script
     self.require(requires)[0].run_script(script_name, ns)
   File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line
 1434, in run_script
     execfile(script_filename, namespace, namespace)
   File "/usr/local/lib/python2.7/dist-packages/xml2rfc-2.4.9dev0-py2.7.egg
 /EGG-INFO/scripts/xml2rfc", line 225, in <module>
     main()
   File "/usr/local/lib/python2.7/dist-packages/xml2rfc-2.4.9dev0-py2.7.egg
 /EGG-INFO/scripts/xml2rfc", line 210, in main
     pagedwriter.write(filename)
   File "/usr/local/lib/python2.7/dist-
 packages/xml2rfc-2.4.9dev0-py2.7.egg/xml2rfc/writers/base.py", line 1180,
 in write
     self._build_index()
   File "/usr/local/lib/python2.7/dist-
 packages/xml2rfc-2.4.9dev0-py2.7.egg/xml2rfc/writers/base.py", line 1022,
 in _build_index
     self._indexRef(ref_counter, title=title, anchor=ref.attrib["anchor"])
   File "lxml.etree.pyx", line 2295, in lxml.etree._Attrib.__getitem__
 (src/lxml/lxml.etree.c:59806)
 KeyError: 'anchor'

 The error occurs whether the PI is symrefs="no" or symrefs="yes".

 A file that triggers the error is attached.

 Presumably the fix is to change the DTD from:
           anchor      ID                 #IMPLIED
 to:
           anchor      ID                 #REQUIRED

 Note: This part of the DTD has been copied over from v1.36. The online v1
 tool also crashes when symrefs="no" but produces a sensible error message
 when symrefs="yes".

-- 
-----------------------------------+----------------------------------
 Reporter:  [email-masked]  |      Owner:  [email-masked]
     Type:  defect                 |     Status:  new
 Priority:  medium                 |  Milestone:
Component:  Version 2 cli          |    Version:  2.4.x
 Keywords:  reference anchor       |
-----------------------------------+----------------------------------

Ticket URL: <http://trac.tools.ietf.org/tools/xml2rfc/trac/ticket/268>
xml2rfc <http://tools.ietf.org/tools/xml2rfc/>