Skip to content

Fix Jinja2 escaping of zsh PROMPT in cloud-init template#41

Merged
ret2libc merged 2 commits intomainfrom
fix-prompt
Feb 23, 2026
Merged

Fix Jinja2 escaping of zsh PROMPT in cloud-init template#41
ret2libc merged 2 commits intomainfrom
fix-prompt

Conversation

@ret2libc
Copy link
Collaborator

The zsh PROMPT string contains % sequences that Jinja2 interprets as template syntax. Wrap in {% raw %}...{% endraw %} to preserve the literal prompt definition.

The zsh PROMPT string contains `%` sequences that Jinja2 interprets
as template syntax. Wrap in {% raw %}...{% endraw %} to preserve
the literal prompt definition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ret2libc ret2libc requested a review from akshithg February 23, 2026 09:38
Copy link
Collaborator

@DarkaMaul DarkaMaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here - but just a question:

would it be better to do the opposite. Wrap everything in {raw} block and leave outside raw blocks only the part that need interpolation

Because jinja needs escaping also for {{ and {#

@ret2libc
Copy link
Collaborator Author

Wouldn't that be messier? There are many lines where the {{username}} is used, and a few other variables or jinja constructs. I would consider using raw everywhere if there were several places where we just need {% or { but they should not be parsed by jinja. I don't see such occurrences apart from here.

@ret2libc ret2libc requested a review from DarkaMaul February 23, 2026 13:34
@DarkaMaul
Copy link
Collaborator

Wouldn't that be messier? There are many lines where the {{username}} is used, and a few other variables or jinja constructs. I would consider using raw everywhere if there were several places where we just need {% or { but they should not be parsed by jinja. I don't see such occurrences apart from here.

I haven't really considered how messy it would be - I was just scared that the next time we're going to modify this file, we may use an escaped syntax.

But you're right, that's a low probability risk.

@ret2libc ret2libc merged commit fde89df into main Feb 23, 2026
7 checks passed
@ret2libc ret2libc deleted the fix-prompt branch February 23, 2026 13:58
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