Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL paths need further escape of single quotes #18006

Open
a4lg opened this issue Oct 8, 2024 · 0 comments · May be fixed by #18007
Open

WSL paths need further escape of single quotes #18006

a4lg opened this issue Oct 8, 2024 · 0 comments · May be fixed by #18007
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.

Comments

@a4lg
Copy link

a4lg commented Oct 8, 2024

Windows Terminal version

1.20.11781.0

Windows build number

10.0.26100.0

Other Software

Ubuntu 24.04 (in WSL and source of Windows.Terminal.Wsl in the profile; any WSL distributions are affected)

Steps to reproduce

  1. Open a WSL tab.
  2. Drag and drop a file/folder (the full path needs at least one single quote ' character), say D:\John's Archive.

Expected Behavior

When

D:\John's Archive

is dropped to a WSL tab, a string which expands to:

/mnt/d/John's Archive

(single argument) in the shell should be dropped.

An example satisfying this condition includes '/mnt/d/John'"'"'s Archive' (escaping a single quote ' with '"'"' (finish quote, print a single quote character then begin quote again).

Note: the expected behavior may differ depending on which environment we should assume.
This expected behavior here is of the POSIX shell context and I think this is reasonable.

Actual Behavior

In the dropped path, single quotes in the original full path are kept as-is (D:\John's Archive'/mnt/d/John's Archive').

This is clearly wrong in the POSIX shell context because a quoted string ends before s and the space after s is not quoted and will not be preserved.

@a4lg a4lg added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 8, 2024
@a4lg a4lg linked a pull request Oct 8, 2024 that will close this issue
4 tasks
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Oct 8, 2024
@carlos-zamora carlos-zamora added Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 9, 2024
@carlos-zamora carlos-zamora added this to the Terminal v1.23 milestone Oct 9, 2024
@carlos-zamora carlos-zamora added the Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) label Oct 9, 2024
a4lg added a commit to a4lg/terminal that referenced this issue Nov 22, 2024
When file/folder is dropped to the terminal, its path is translated and
quoted with a pair of single quotes if necessary.

However, despite that the Win32 subsystem allows single quote, the
terminal control does not escape it.  It causes a path containing one or
more single quotes incorrect on the POSIX shell context
(see Issue microsoft#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).
a4lg added a commit to a4lg/terminal that referenced this issue Nov 22, 2024
When file/folder is dropped to the terminal, its path is translated and
quoted with a pair of single quotes if necessary.

However, despite that the Win32 subsystem allows single quote, the
terminal control does not escape it.  It causes a path containing one or
more single quotes incorrect on the POSIX shell context
(see Issue microsoft#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).
a4lg added a commit to a4lg/terminal that referenced this issue Nov 22, 2024
When file/folder is dropped to the terminal, its path is translated and
quoted with a pair of single quotes if necessary.

However, despite that the Win32 subsystem allows single quote, the
terminal control does not escape it.  It causes a path containing one or
more single quotes incorrect on the POSIX shell context
(see Issue microsoft#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).
a4lg added a commit to a4lg/terminal that referenced this issue Nov 23, 2024
When file/folder is dropped to the terminal, its path is translated and
quoted with a pair of single quotes if necessary.

However, despite that the Win32 subsystem allows single quote, the
terminal control does not escape it.  It causes a path containing one or
more single quotes incorrect on the POSIX shell context
(see Issue microsoft#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants