mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Check safety of save_as earlier if possible
The check in the writer still serves as a safety net.
This commit is contained in:
parent
4006554a49
commit
018f4468cc
5 changed files with 103 additions and 18 deletions
|
|
@ -36,6 +36,18 @@ except ImportError:
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def sanitised_join(base_directory, *parts):
|
||||
joined = os.path.abspath(os.path.join(base_directory, *parts))
|
||||
if not joined.startswith(os.path.abspath(base_directory)):
|
||||
raise RuntimeError(
|
||||
"Attempted to break out of output directory to {}".format(
|
||||
joined
|
||||
)
|
||||
)
|
||||
|
||||
return joined
|
||||
|
||||
|
||||
def strftime(date, date_format):
|
||||
'''
|
||||
Replacement for built-in strftime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue