Repository navigation
🐛 fix(xonsh): preserve values across codecs - #3668
Merged
Merged
Conversation
gaborbernat
force-pushed
the
fix/y91-xonsh-utf7
branch
from
November 20, 2026 07:33
4cef0ff to
7803d32
Compare
gaborbernat
force-pushed
the
fix/y91-xonsh-utf7
branch
2 times, most recently
from
November 20, 2026 09:10
1854e5e to
2eecce9
Compare
Xonsh can decode an activation script with UTF-7, which interprets printable plus sequences before Python parses the generated values. Represent affected characters by code point so the source decoder cannot change a value into syntax.
A Xonsh session can bind chr or map before sourcing the script, which would stop activation for values that need a code-point expression. Resolve both through builtins. Keep ascii() for plain values so the existing CodeQL quote rule still recognizes the safe branch.
The Tcl and Tk test assumed every generated value remained a literal. Windows Unicode paths now use code point expressions. Execute the rendered assignments and compare their resulting values.
gaborbernat
force-pushed
the
fix/y91-xonsh-utf7
branch
from
November 20, 2026 10:54
2eecce9 to
f8e00d2
Compare
gaborbernat
marked this pull request as ready for review
November 20, 2026 10:56
This was referenced Nov 20, 2026
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.
At the merge base, Xonsh activation embedded prompt and destination values using
ascii(). Xonsh'ssourcecommand decodes the generated script with$XONSH_ENCODINGbefore parsing Python syntax. Under UTF-7, decoded prompt text could become syntax when a user sourced an environment created from a lower-trust prompt. The renderer now constructs affected characters from code points. This addresses draft advisory ANT-2026-Y91OJFTQ.Source decoding could change the literal
The template substitution inserts quoted values into executable Xonsh assignments.
ascii()kept non-ASCII characters out of those assignments, but left printable punctuation that some source codecs reinterpret. The new quote function emits an ordinary literal for unaffected ASCII values and an expression built from code points for characters that source codecs can reinterpret.sequenceDiagram participant P as Prompt supplier participant V as virtualenv participant F as activate.xsh participant X as Xonsh source P->>+V: Provide prompt text rect rgb(255, 214, 214) V->>+F: Before: write punctuation in a literal F->>+X: Decode source as UTF-7 X-->>X: Decoded text changes Python syntax end rect rgb(216, 243, 220) V->>F: Now: write expression from code points F->>X: Decode source as UTF-7 X-->>X: Reconstruct original prompt value end deactivate X deactivate F deactivate VBehavior changes
Xonsh preserves prompt and destination values containing characters that UTF-7 could reinterpret when it sources a regenerated script. Ordinary ASCII values still use Python literals; affected values make the generated script longer. Existing environments need their activation scripts regenerated. This change does not address the separate legacy
activate_this.pyloader described in the report.Reported by
oss-scanner: ANT-2026-Y91OJFTQ.