Skip to content

configure Jinja autoescaping by template type to avoid Markup usage …#2136

Closed
UlrichB22 wants to merge 1 commit intomoinwiki:masterfrom
UlrichB22:xml_autoescape
Closed

configure Jinja autoescaping by template type to avoid Markup usage …#2136
UlrichB22 wants to merge 1 commit intomoinwiki:masterfrom
UlrichB22:xml_autoescape

Conversation

@UlrichB22
Copy link
Copy Markdown
Collaborator

…for XML

Disable Jinja autoescaping for .xml templates, keep it enabled for HTML.
This allows rendering pre-escaped XML output without using markupsafe.Markup
and avoids Bandit warnings B701/B704.

Related to #1858.

@roland-ruedenauer
Copy link
Copy Markdown
Contributor

Disabling Jinja autoescaping for XML templates would work as there is only a limited number of uses in Moin. Nevertheless, it seems not to be recommended.

An alternative solution woud be to make use of a baseline file to suppress reporting of already validated uses of Markup() or other bandit findings.

Function escape should be added to allowed_calls in section markupsafe_css.

@UlrichB22 UlrichB22 marked this pull request as draft February 5, 2026 08:55
@UlrichB22
Copy link
Copy Markdown
Collaborator Author

Thanks for your review.

An alternative solution woud be to make use of a baseline file to suppress reporting of already validated uses of Markup() or other bandit findings.

IMO using baselines only hides the problems. I prefer to keep them visible in the code.

I am working on a general solution for Markup and will close this PR later.

@UlrichB22
Copy link
Copy Markdown
Collaborator Author

Replaced by #2151

@UlrichB22 UlrichB22 closed this Feb 10, 2026
@UlrichB22 UlrichB22 deleted the xml_autoescape branch February 11, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants