Skip to content

Commit

Permalink
fix: Exit gracefully on artwork and sourcecode src file access errors
Browse files Browse the repository at this point in the history
Fixes #1125
  • Loading branch information
kesara committed Jan 16, 2025
1 parent 6aeed83 commit b93eac9
Showing 1 changed file with 3 additions and 6 deletions.
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

0 comments on commit b93eac9

Please sign in to comment.