def _replace_includes(self, apibp):
matches = re.findall(r'<!-- include\((.*)\) -->', apibp)
for match in matches:
include_path = safe_join(os.path.dirname(self.blueprint), match)
if not self._is_whitelisted(include_path):
raise SuspiciousFileOperation("extension not in whitelist")
# recursively replace any includes in child files
include_apibp = self._replace_includes(
open(include_path, 'r').read())
apibp = apibp.replace(
'<!-- include(' + match + ') -->', include_apibp)
return apibp
评论列表
文章目录