fix(config): Keep template spans intact in command strings - #878
Open
JeanMertz wants to merge 2 commits into
Open
fix(config): Keep template spans intact in command strings#878JeanMertz wants to merge 2 commits into
JeanMertz wants to merge 2 commits into
Conversation
Command strings written as plain strings (rather than the structured
`program`/`args` form) are split into shell words before minijinja
renders any `{{ }}`, `{% %}`, or `{# #}` spans. Until now that split
used `shlex::split` directly, so a template expression containing
spaces was torn across multiple arguments, e.g. `just x {{ a |
default('') }}` produced `args: ["x", "{{", "a", "|", "default('')",
"}}"]` instead of a single argument.
Template spans are now masked with NUL-delimited placeholders before
the shell split and restored afterwards, so a span survives as one
argument even when it contains spaces or quoted filter arguments.
String literals inside expression/statement spans are tracked so a
`}}`/`%}` inside a quoted string does not end the span early, and an
unterminated span is kept whole rather than mangled, leaving the
error to minijinja at render time. Quotes inside a span (e.g. inside
a `{# comment #}`) no longer trip the unbalanced-shell-quoting check.
This only affects the string form of `CommandConfigOrString`; the
structured `program`/`args` form is unaffected.
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Command strings written as plain strings (rather than the structured
program/argsform) are split into shell words before minijinja renders any{{ }},{% %}, or{# #}spans. Until now that split usedshlex::splitdirectly, so a template expression containing spaces was torn across multiple arguments, e.g.just x {{ a | default('') }}producedargs: ["x", "{{", "a", "|", "default('')", "}}"]instead of a single argument.Template spans are now masked with NUL-delimited placeholders before the shell split and restored afterwards, so a span survives as one argument even when it contains spaces or quoted filter arguments. String literals inside expression/statement spans are tracked so a
}}/%}inside a quoted string does not end the span early, and an unterminated span is kept whole rather than mangled, leaving the error to minijinja at render time. Quotes inside a span (e.g. inside a{# comment #}) no longer trip the unbalanced-shell-quoting check.This only affects the string form of
CommandConfigOrString; the structuredprogram/argsform is unaffected.