Check for files that are outside the source dir in build_specific().

This commit is contained in:
Georg Brandl 2009-04-11 12:49:45 +02:00
parent b966975ca6
commit 46bc1cbe4b
2 changed files with 14 additions and 2 deletions

View File

@ -1,6 +1,9 @@
Release 0.6.2 (in development)
==============================
* If specific filenames to build are given on the command line,
check that they are within the source directory.
* Fix autodoc crash for objects without a ``__name__``.
* Fix intersphinx for installations without urllib2.HTTPSHandler.

View File

@ -234,10 +234,19 @@ class Builder(object):
to_write = []
suffix = self.config.source_suffix
for filename in filenames:
filename = path.abspath(filename)[dirlen:]
filename = path.normpath(path.abspath(filename))
if not filename.startswith(self.srcdir):
self.warn('file %r given on command line is not under the '
'source directory, ignoring' % filename)
continue
if not (path.isfile(filename) or path.isfile(filename + suffix)):
self.warn('file %r given on command line does not exist, '
'ignoring' % filename)
continue
filename = filename[dirlen:]
if filename.endswith(suffix):
filename = filename[:-len(suffix)]
filename = filename.replace(os.path.sep, SEP)
filename = filename.replace(path.sep, SEP)
to_write.append(filename)
self.build(to_write, method='specific',
summary='%d source files given on command '