Skip to content

Commit

Permalink
fix: Warn when reference uses PIs (#1007)
Browse files Browse the repository at this point in the history
`XInclude` should be used instead of ENTITY references and
XML Processing Instructions (PIs) that allow external inclusions [1].

This change adds a warning when include PIs (<?rfc include='<reference>' ?>)
are used with xml2rfc v3.

Fixes #1006

[1] https://datatracker.ietf.org/doc/html/rfc7991#appendix-B.1
  • Loading branch information
kesara authored Jun 19, 2023
1 parent 8cbc6c6 commit f92f551
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions xml2rfc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ def parse(self, remove_comments=True, remove_pis=False, quiet=False, strip_cdata
pis = xmlrfc.pis.copy()
if 'include' in pidict and pidict['include']:
request = pidict['include']
if xmlrfc.getroot().get('version', '3') in ['3', ]:
xml2rfc.log.warn(f'XInclude should be used instead of PI include for {request}')
path = self.cachingResolver.getReferenceRequest(request,
# Pass the line number in XML for error bubbling
include=True, line_no=getattr(element, 'sourceline', 0))
Expand Down

0 comments on commit f92f551

Please sign in to comment.