xml2rfc icon indicating copy to clipboard operation
xml2rfc copied to clipboard

Empty xref / relfref section with non empty relative attribute crashes xml2rfc

Open kesara opened this issue 1 year ago • 7 comments

Describe the issue

Example draft:

<?xml version="1.0" encoding="utf-8"?>
<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc comments="yes"?>

<rfc ipr="trust200902" docName="draft-foobar-00" category="exp" submissionType="IETF">
  <front>
    <title abbrev="foobar">Foobar</title>
    <author initials="J." surname="Doe" fullname="Jane Doe">
      <address>
        <postal>
          <country>New Zealand</country>
        </postal>
        <email>[email protected]</email>
      </address>
    </author>

    <abstract>
      <t>Foobar</t>
    </abstract>
  </front>

  <middle>
    <section anchor="introduction" title="Introduction">
      <t>
     Registration policy (see <relref target="RFC8126" section="" relative="section-4" derivedLink="https://www.rfc-editor.org/rfc/rfc8126.html#section-4">RFC 8126 section 4</relref> for details):
        </t>
    </section>
  </middle>

  <back>
 <references><name>Normative References</name>
  <reference anchor="RFC8126">
   <front>
    <title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
    <author></author>
   </front>
   <seriesInfo name='RFC' value='8126'/>
  </reference>
 </references>
  </back>
</rfc>

The empty section="" causes xml2rfc crash without providing useful output. This bug doesn't affect the text output. NOTE that relref is a deprecated element in xml2rfc v3.

CC @dthaler

Code of Conduct

kesara avatar Nov 07 '23 16:11 kesara

NOTE that relref is a deprecated element in xml2rfc v3.

Where is that stated? RFC 7991 doesn't say that anywhere I can find, and in fact says relref is new in xml2rfc v3.

dthaler avatar Nov 07 '23 17:11 dthaler

On 2023-11-07, at 18:50, Dave Thaler @.***> wrote:

NOTE that relref is a deprecated element in xml2rfc v3.

Where is that stated? RFC 7991 doesn't say that anywhere I can find, and in fact says relref is new in xml2rfc v3.

Well, RFCXML has changed in the last 7 years. Unfortunately, the documents haven’t kept up, because we didn’t have RSAB/RSWG yet.

First we had https://datatracker.ietf.org/doc/html/draft-levkowetz-xml2rfc-v3-implementation-notes-13

then https://www.ietf.org/archive/id/draft-iab-rfc7991bis-04.html#name-elements-and-attributes-dep (Check the list of deprecations.)

The only real documentation of RFCXML at this point is in the xml2rfc source:

https://ietf-tools.github.io/xml2rfc/

Section 3.1 https://ietf-tools.github.io/xml2rfc/#name-elements-from-v2-that-have- is slightly broken :-)

Grüße, Carsten

cabo avatar Nov 07 '23 18:11 cabo

This issue isn't specific to relref. If relref is changed to xref, the same issue still occurs.

dthaler avatar Nov 08 '23 08:11 dthaler

@dthaler Yeah, the bug exists in both relref and xref when the section is empty and relative is not empty. xml2rfc should not crash but rather warn or spit out an error in these cases.

kesara avatar Nov 08 '23 10:11 kesara

In RST, links look like this:

`RFC 8126 section 4 <https://www.rfc-editor.org/rfc/rfc8126.html#section-4>`_

What should this look like in XML?
From my reading of https://www.ietf.org/archive/id/draft-iab-rfc7991bis-04.html#element.xref, is the following the right thing?

<xref target="RFC8126" section="4" relative="#section-4" derivedLink="https://www.rfc-editor.org/rfc/rfc8126.html#section-4">RFC 8126</xref>

dthaler avatar Nov 08 '23 10:11 dthaler

The bare minimum required is <xref target="RFC8126" section="4"/> to get Section 4 of [RFC8126]. You can get customized results by using the sectionFormat attribute.

kesara avatar Nov 08 '23 11:11 kesara

<xref target="RFC8126" section="4" relative="#section-4" derivedLink="https://www.rfc-editor.org/rfc/rfc8126.html#section-4">RFC 8126</xref>

Better let xml2rfc do the derivedLink=. For RFCs, you don't have to give a relative=, xml2rfc will do that for you (and implement its arcane convention for this).

<xref target="RFC8126" section="4" >RFC 8126</xref>

add sectionFormat to taste.

cabo avatar Nov 08 '23 11:11 cabo