Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/changelog.d/754.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Minor improvements in ``jinja`` auto escape and ``subprocess`` call
10 changes: 8 additions & 2 deletions src/ansys_sphinx_theme/cheatsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"""

import pathlib
import subprocess

# Excudind bandit rule B404 as we are using subprocess to run commands
# and we are handling the command execution securely.
import subprocess # nosec: B404
from typing import List, Optional

from sphinx.application import Sphinx
Expand Down Expand Up @@ -103,7 +106,10 @@ def run_quarto_command(command: List[str], cwd: str) -> None:
"""
command = ["quarto"] + command
try:
result = subprocess.run(command, cwd=cwd, check=True, capture_output=True, text=True)
# Excluding bandit rule because subprocess is using quarto command
# and we are handling the command execution securely.
# The command is run in a controlled environment and not accepting user input.
result = subprocess.run(command, cwd=cwd, check=True, capture_output=True, text=True) # nosec: B603
if result.stdout:
logger.info(result.stdout)

Expand Down
4 changes: 2 additions & 2 deletions src/ansys_sphinx_theme/latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def generate_preamble(title, watermark="watermark", date=None):
line_statement_prefix="%%",
line_comment_prefix="%#",
trim_blocks=True,
autoescape=False,
autoescape=True,
loader=jinja2.FileSystemLoader(COVER_TEX),
)
template = latex_jinja_env.get_template(".")
Expand Down Expand Up @@ -100,6 +100,6 @@ def generate_404(
variables = dict(
issue_page=issue_page, project_name=project_name, mail_id=mail_id, team_name=team_name
)
html_env = jinja2.Environment(loader=jinja2.FileSystemLoader(PAGE_404))
html_env = jinja2.Environment(loader=jinja2.FileSystemLoader(PAGE_404), autoescape=True)
template = html_env.get_template(".")
return template.render(variables)
Loading