Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Exit gracefully on artwork and sourcecode src file access errors #1203

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/valid/indexes.pages.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group H. Person, Ed.
Internet-Draft January 10, 2025
Internet-Draft January 16, 2025
Intended status: Experimental
Expires: July 14, 2025
Expires: July 20, 2025


xml2rfc index tests
Expand All @@ -26,7 +26,7 @@ Status of This Memo
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."

This Internet-Draft will expire on July 14, 2025.
This Internet-Draft will expire on July 20, 2025.

Copyright Notice

Expand All @@ -53,7 +53,7 @@ Table of Contents



Person Expires July 14, 2025 [Page 1]
Person Expires July 20, 2025 [Page 1]

Internet-Draft xml2rfc index tests January 2025

Expand Down Expand Up @@ -109,7 +109,7 @@ Index



Person Expires July 14, 2025 [Page 2]
Person Expires July 20, 2025 [Page 2]

Internet-Draft xml2rfc index tests January 2025

Expand Down Expand Up @@ -165,4 +165,4 @@ Author's Address



Person Expires July 14, 2025 [Page 3]
Person Expires July 20, 2025 [Page 3]
6 changes: 3 additions & 3 deletions tests/valid/indexes.prepped.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" sortRefs="true" category="exp" submissionType="independent" ipr="trust200902" docName="indexes-00" indexInclude="true" prepTime="2025-01-10T04:34:27" scripts="Common,Latin" symRefs="true" tocDepth="3" tocInclude="true">
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" sortRefs="true" category="exp" submissionType="independent" ipr="trust200902" docName="indexes-00" indexInclude="true" prepTime="2025-01-16T08:49:46" scripts="Common,Latin" symRefs="true" tocDepth="3" tocInclude="true">
<!-- xml2rfc v2v3 conversion 3.25.0 -->


Expand All @@ -20,7 +20,7 @@
</postal>
</address>
</author>
<date day="10" month="01" year="2025"/>
<date day="16" month="01" year="2025"/>
<boilerplate>
<section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
<name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
Expand All @@ -41,7 +41,7 @@
material or to cite them other than as "work in progress."
</t>
<t indent="0" pn="section-boilerplate.1-4">
This Internet-Draft will expire on 14 July 2025.
This Internet-Draft will expire on 20 July 2025.
</t>
</section>
<section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/indexes.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group H. Person, Ed.
Internet-Draft January 10, 2025
Internet-Draft January 16, 2025
Intended status: Experimental
Expires: July 14, 2025
Expires: July 20, 2025


xml2rfc index tests
Expand All @@ -26,7 +26,7 @@ Status of This Memo
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."

This Internet-Draft will expire on July 14, 2025.
This Internet-Draft will expire on July 20, 2025.

Copyright Notice

Expand Down
8 changes: 4 additions & 4 deletions tests/valid/indexes.v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</tr></thead>
<tfoot><tr>
<td class="left">Person</td>
<td class="center">Expires July 14, 2025</td>
<td class="center">Expires July 20, 2025</td>
<td class="right">[Page]</td>
</tr></tfoot>
</table>
Expand All @@ -36,12 +36,12 @@
<dd class="internet-draft">indexes-00</dd>
<dt class="label-published">Published:</dt>
<dd class="published">
<time datetime="2025-01-10" class="published">January 10, 2025</time>
<time datetime="2025-01-16" class="published">January 16, 2025</time>
</dd>
<dt class="label-intended-status">Intended Status:</dt>
<dd class="intended-status">Experimental</dd>
<dt class="label-expires">Expires:</dt>
<dd class="expires"><time datetime="2025-07-14">July 14, 2025</time></dd>
<dd class="expires"><time datetime="2025-07-20">July 20, 2025</time></dd>
<dt class="label-authors">Author:</dt>
<dd class="authors">
<div class="author">
Expand Down Expand Up @@ -71,7 +71,7 @@ <h2 id="name-status-of-this-memo">
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."<a href="#section-boilerplate.1-3" class="pilcrow">¶</a></p>
<p id="section-boilerplate.1-4">
This Internet-Draft will expire on July 14, 2025.<a href="#section-boilerplate.1-4" class="pilcrow">¶</a></p>
This Internet-Draft will expire on July 20, 2025.<a href="#section-boilerplate.1-4" class="pilcrow">¶</a></p>
</section>
</div>
<div id="copyright">
Expand Down
2 changes: 1 addition & 1 deletion tests/valid/manpage.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xml2rfc(1) xml2rfc(1)
10 January 2025
16 January 2025


Xml2rfc Vocabulary Version 3 Schema
Expand Down
14 changes: 7 additions & 7 deletions tests/valid/sourcecode.pages.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group H. Person, Ed.
Internet-Draft January 10, 2025
Internet-Draft January 16, 2025
Intended status: Experimental
Expires: July 14, 2025
Expires: July 20, 2025


xml2rfc sourcecode tests
Expand All @@ -26,7 +26,7 @@ Status of This Memo
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."

This Internet-Draft will expire on July 14, 2025.
This Internet-Draft will expire on July 20, 2025.

Copyright Notice

Expand All @@ -53,7 +53,7 @@ Table of Contents



Person Expires July 14, 2025 [Page 1]
Person Expires July 20, 2025 [Page 1]

Internet-Draft xml2rfc sourcecode tests January 2025

Expand Down Expand Up @@ -109,7 +109,7 @@ Internet-Draft xml2rfc sourcecode tests January 2025



Person Expires July 14, 2025 [Page 2]
Person Expires July 20, 2025 [Page 2]

Internet-Draft xml2rfc sourcecode tests January 2025

Expand Down Expand Up @@ -165,7 +165,7 @@ Internet-Draft xml2rfc sourcecode tests January 2025



Person Expires July 14, 2025 [Page 3]
Person Expires July 20, 2025 [Page 3]

Internet-Draft xml2rfc sourcecode tests January 2025

Expand Down Expand Up @@ -221,4 +221,4 @@ Author's Address



Person Expires July 14, 2025 [Page 4]
Person Expires July 20, 2025 [Page 4]
6 changes: 3 additions & 3 deletions tests/valid/sourcecode.prepped.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" sortRefs="true" category="exp" submissionType="independent" ipr="trust200902" docName="sourcecode-00" prepTime="2025-01-10T04:34:37" indexInclude="true" scripts="Common,Latin" symRefs="true" tocDepth="3" tocInclude="true">
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" sortRefs="true" category="exp" submissionType="independent" ipr="trust200902" docName="sourcecode-00" prepTime="2025-01-16T08:49:56" indexInclude="true" scripts="Common,Latin" symRefs="true" tocDepth="3" tocInclude="true">
<!-- xml2rfc v2v3 conversion 3.25.0 -->


Expand All @@ -20,7 +20,7 @@
</postal>
</address>
</author>
<date day="10" month="01" year="2025"/>
<date day="16" month="01" year="2025"/>
<boilerplate>
<section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
<name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
Expand All @@ -41,7 +41,7 @@
material or to cite them other than as "work in progress."
</t>
<t indent="0" pn="section-boilerplate.1-4">
This Internet-Draft will expire on 14 July 2025.
This Internet-Draft will expire on 20 July 2025.
</t>
</section>
<section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/sourcecode.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group H. Person, Ed.
Internet-Draft January 10, 2025
Internet-Draft January 16, 2025
Intended status: Experimental
Expires: July 14, 2025
Expires: July 20, 2025


xml2rfc sourcecode tests
Expand All @@ -26,7 +26,7 @@ Status of This Memo
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."

This Internet-Draft will expire on July 14, 2025.
This Internet-Draft will expire on July 20, 2025.

Copyright Notice

Expand Down
8 changes: 4 additions & 4 deletions tests/valid/sourcecode.v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</tr></thead>
<tfoot><tr>
<td class="left">Person</td>
<td class="center">Expires July 14, 2025</td>
<td class="center">Expires July 20, 2025</td>
<td class="right">[Page]</td>
</tr></tfoot>
</table>
Expand All @@ -36,12 +36,12 @@
<dd class="internet-draft">sourcecode-00</dd>
<dt class="label-published">Published:</dt>
<dd class="published">
<time datetime="2025-01-10" class="published">January 10, 2025</time>
<time datetime="2025-01-16" class="published">January 16, 2025</time>
</dd>
<dt class="label-intended-status">Intended Status:</dt>
<dd class="intended-status">Experimental</dd>
<dt class="label-expires">Expires:</dt>
<dd class="expires"><time datetime="2025-07-14">July 14, 2025</time></dd>
<dd class="expires"><time datetime="2025-07-20">July 20, 2025</time></dd>
<dt class="label-authors">Author:</dt>
<dd class="authors">
<div class="author">
Expand Down Expand Up @@ -71,7 +71,7 @@ <h2 id="name-status-of-this-memo">
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."<a href="#section-boilerplate.1-3" class="pilcrow">¶</a></p>
<p id="section-boilerplate.1-4">
This Internet-Draft will expire on July 14, 2025.<a href="#section-boilerplate.1-4" class="pilcrow">¶</a></p>
This Internet-Draft will expire on July 20, 2025.<a href="#section-boilerplate.1-4" class="pilcrow">¶</a></p>
</section>
</div>
<div id="copyright">
Expand Down
9 changes: 3 additions & 6 deletions xml2rfc/writers/preptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,15 +1719,12 @@ def check_src_file_path(self, e, scheme, netloc, path, query, fragment):
dir = os.path.abspath(os.path.dirname(self.xmlrfc.source))
path = os.path.abspath(os.path.join(dir, path))
if not path.startswith(dir):
self.err(e, "Expected an <%s> src= file located beside or below the .xml source (in %s), but found a reference to %s" % (e.tag, dir, path))
return None
self.die(e, "Expected an <%s> src= file located beside or below the .xml source (in %s), but found a reference to %s" % (e.tag, dir, path))
src = urlunsplit((scheme, '', path, '', ''))
if shellmeta.search(src):
self.err(e, "Found disallowed shell meta-characters in the src='file:...' attribute")
return None
self.die(e, "Found disallowed shell meta-characters in the src='file:...' attribute")
if not os.path.exists(path):
self.err(e, "Expected an <%s> src= file at '%s', but no such file exists" % (e.tag, path, ))
return None
self.die(e, "Expected an <%s> src= file at '%s', but no such file exists" % (e.tag, path, ))
#
e.set('src', src)
return src
Expand Down
Loading