Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): _render safe to false when there is inverted section #1042

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion keep/iohandler/iohandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,16 @@ def _parse(self, tree):
tree = ast.parse(token.encode("unicode_escape"))
return _parse(self, tree)

def _render(self, key, safe=False, default=""):
def _render(self, key: str, safe=False, default=""):
# change [] to . for the key because thats what chevron uses
_key = key.replace("[", ".").replace("]", "")

if "{{^" in key or "{{ ^" in key:
self.logger.debug(
"Safe render is not supported when there are inverted sections."
)
safe = False

context = self.context_manager.get_full_context()
# TODO: protect from multithreaded where another thread will print to stderr, but thats a very rare case and we shouldn't care much
original_stderr = sys.stderr
Expand Down
Loading