Skip to content

fix: preserve literal backslashes in quoted user directories - #614

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
xiehuanyi:fix-user-dirs-literal-backslashes
Oct 11, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
xiehuanyi:fix-user-dirs-literal-backslashes

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Before this change, a double-quoted user-dirs.dirs entry such as XDG_DOCUMENTS_DIR="/data/a\q" resolved to /data/aq. Shell double quotes preserve \q, so the directory name changed.

Unescape only $, backticks, double quotes, and backslashes. Keep $HOME prefix expansion and bare-value handling. The xdg-user-dir utility still removes a backslash before an ordinary character in a hand-written entry; \\ gives the same result in both readers. The Unix docs explain this difference.

Regression cases cover ordinary, special, and mixed escapes with absolute and $HOME paths. Linux checks pass on Python 3.11 and 3.15, along with tox type, fix, and docs. Changed-line coverage is 100%. pre-commit.ci passes after using python3 for hook environments.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

pre-commit.ci cannot find python3.15 and fails before running any hooks.
Use python3 so hook environments use an installed interpreter.

Document the different backslash handling in xdg-user-dir and cover
mixed escapes.
@gaborbernat
gaborbernat force-pushed the fix-user-dirs-literal-backslashes branch from 20e55ea to 7587176 Compare October 10, 2026 22:40
@gaborbernat
gaborbernat enabled auto-merge (squash) October 10, 2026 22:51
@gaborbernat
gaborbernat merged commit dba53cd into tox-dev:main Oct 11, 2026
33 checks passed
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.

3 participants