Commit 9e708961 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Need to perform the local assertion before checking for existence.

parent 3c25384f
...@@ -262,21 +262,20 @@ class ConfigHandler(object): ...@@ -262,21 +262,20 @@ class ConfigHandler(object):
spec = value[len(include_directive):] spec = value[len(include_directive):]
filepaths = (os.path.abspath(path.strip()) for path in spec.split(',')) filepaths = (os.path.abspath(path.strip()) for path in spec.split(','))
return '\n'.join( return '\n'.join(
cls._read_local_file(path) cls._read_file(path)
for path in filepaths for path in filepaths
if os.path.isfile(path) if (cls._assert_local(path) or True)
and os.path.isfile(path)
) )
@staticmethod @staticmethod
def _read_local_file(filepath): def _assert_local(filepath):
"""
Read contents of filepath. Raise error if the file
isn't in the current directory.
"""
if not filepath.startswith(os.getcwd()): if not filepath.startswith(os.getcwd()):
raise DistutilsOptionError( raise DistutilsOptionError(
'`file:` directive can not access %s' % filepath) '`file:` directive can not access %s' % filepath)
@staticmethod
def _read_file(filepath):
with io.open(filepath, encoding='utf-8') as f: with io.open(filepath, encoding='utf-8') as f:
return f.read() return f.read()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment