[PR #18007] Escape single quotes while translating dropped Win32 paths #31424

Open
opened 2026-01-31 09:47:12 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/18007

State: closed
Merged: Yes


Summary of the Pull Request

When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary.

However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated.

On the translation styles other than "none" (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example).

With this commit, the terminal control escapes a single quote with a valid escape sequence '\'' (finish quote, print a single quote then begin quote again) when the path translation is required.

History

v1 → v2

  • Changed escape sequence from '"'"' to much shorter '\''.
  • Reflected comments by the reviewer.

v2 → v3

  • Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS).
  • More clarification both in the code and in the commit message.

v3 → v4 (current)

  • Minor clarification both in the code and in the commit message.

References and Relevant Issues

Detailed Description of the Pull Request / Additional comments

This is a follow-up of #16214 and #18195, fixing #18006.

Validation Steps Performed

PR Checklist

**Original Pull Request:** https://github.com/microsoft/terminal/pull/18007 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary. However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated. On the translation styles other than `"none"` (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example). With this commit, the terminal control escapes a single quote with a valid escape sequence `'\''` (finish quote, print a single quote then begin quote again) when the path translation is required. ## History ### v1 → v2 * Changed escape sequence from `'"'"'` to much shorter `'\''`. * Reflected comments by the reviewer. ### v2 → v3 * Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS). * More clarification both in the code and in the commit message. ### v3 → v4 (current) * Minor clarification both in the code and in the commit message. ## References and Relevant Issues * #18006 * #16214 * #18195 ## Detailed Description of the Pull Request / Additional comments This is a follow-up of #16214 and #18195, fixing #18006. ## Validation Steps Performed ## PR Checklist - [x] Closes #18006 - [ ] Tests added/passed - [ ] Documentation updated - If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx - [ ] Schema updated (if necessary)
claunia added the pull-request label 2026-01-31 09:47:12 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31424