From 3d0c09857515963a66cb0e5f3c7b0c4a47d6d6b2 Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Thu, 16 Apr 2020 14:53:59 +0200 Subject: [PATCH] naievly copy other includes as well --- main.py | 197 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 162 insertions(+), 35 deletions(-) diff --git a/main.py b/main.py index ce9a4e8..1351555 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,151 @@ import os from pathlib import Path import shutil +def make_safe(path): + # make sure the path does not climb up + + path = Path(path) + while len(path.parts) > 0 and path.parts[0] == "..": + path = Path(*path.parts[1:]) + + return path + +def contains_envvars(path): + for part in path.parts: + if str(part)[0] == "$": + return True + + return False + +def find_file_refs(content, location): + temp = "" + last = 0 + + files = {} + fileregex = re.compile(r"(?