Skip to content

Commit

Permalink
Disable autoescape in minijinja for YAML rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Nov 25, 2024
1 parent c79e7e9 commit 9396328
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions course/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,8 @@ def expand_yaml_macros(repo: Repo_ish, commit_sha: bytes, yaml_str: str) -> str:
from minijinja import Environment
jinja_env = Environment(
loader=YamlBlockEscapingGitTemplateLoader(repo, commit_sha),
undefined_behavior="strict")
undefined_behavior="strict",
auto_escape_callback=lambda fn: False)

# {{{ process explicit [JINJA] tags (deprecated)

Expand Down Expand Up @@ -1099,8 +1100,7 @@ def get_yaml_from_repo(
raise ValueError("File uses tabs in indentation. "
"This is not allowed.")

expanded = expand_yaml_macros(
repo, commit_sha, yaml_bytestream)
expanded = expand_yaml_macros(repo, commit_sha, yaml_bytestream)

yaml_data = load_yaml(expanded) # type:ignore
result = dict_to_struct(yaml_data)
Expand Down
4 changes: 3 additions & 1 deletion relate/bin/relate.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def expand_yaml(yml_file, repo_root):
from minijinja import Environment
jinja_env = Environment(
loader=YamlBlockEscapingFileSystemLoader(repo_root),
undefined_behavior="strict")
undefined_behavior="strict",
auto_escape_callback=lambda fn: False,
)

return jinja_env.render_str(data)

Expand Down

0 comments on commit 9396328

Please sign in to comment.