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

Bang/Exclamation mark (!) not escaped when pasting paths #1579

Open
damisan opened this Issue May 25, 2018 · 5 comments

Comments

2 participants
@damisan

damisan commented May 25, 2018

Versions

ConEmu build: 180506 x32/x64
OS version: Windows 7 x64
Used shell version: msys2

Problem description

Bangs in paths are not escaped on Windows to POSIX conversion (drag-and-drop, pasete, ...)

Steps to reproduce

A

  1. Copy path to clipboard "c:\folder!bang" (without quotes)
  2. Paste into ConEmu (right mouse click)

B

  1. Create folder c:\folder!bang
  2. Drag-and-drop the folder to ConEmu

Actual results

/c/folder!bang
(missing \ before !)

Expected results

/c/folder\!bang

@damisan

This comment has been minimized.

damisan commented May 25, 2018

It seems to be enough to add ! to the else part in posixSpec (ConEmuApp.cpp line 649)
const wchar_t* posixSpec = bAutoQuote ? L"$" : L" ()$!";

@Maximus5

This comment has been minimized.

Owner

Maximus5 commented May 25, 2018

Almost. It should be

const wchar_t* posixSpec = bAutoQuote ? L"$!" : L" ()$!";
@damisan

This comment has been minimized.

damisan commented May 25, 2018

Escaping ! in quoted string doesn't work in mingw/bash

# Double quoted, escaped with \
$ cd "c:\folder with space\spaces and bang \!\! bang"
bash: cd: c:\folder with space\spaces and bang \!\! bang: No such file or directory

# Single quoted, escaped with \
$ cd 'c:\folder with space\spaces and bang \!\! bang'
bash: cd: c:\folder with space\spaces and bang \!\! bang: No such file or directory

# Double quoted, unescaped
$ cd "c:\folder with space\spaces and bang !! bang"
# WRONG: some command history magic happening

# Single quoted, unescaped
$ cd 'c:\folder with space\spaces and bang !! bang'
# OK

# Unquoted, \-escapd
$ cd /c/folder\ with\ space/spaces\ and\ bang\ \!\!\ bang
# OK, but looks ugly compared to the single quoted, unescaped

# Double quoted + single quoted !
$ cd "c:\folder with space\spaces and bang "'!!'" bang"
# OK

So autoQuoting should be done with single quotes to avoid "'!'" quoting.

But I found now way to enable pasting/d'n'd-ing quoted paths, thus I was unable to test it.
Moreover: I would just prefer POSIX path conversion to produce quoted string (only when needed) if favor of escaping every single space etc.

@damisan

This comment has been minimized.

damisan commented May 27, 2018

In what version of mingw/bash?

The most recent one

$ bash --version
GNU bash, version 4.4.19(2)-release (x86_64-pc-msys)

In what version in actually does work?

@Maximus5

This comment has been minimized.

Owner

Maximus5 commented May 27, 2018

Reading about quoting: http://wiki.bash-hackers.org/syntax/quoting

Consider following changes:

  • DupCygwinPath would be called with bAutoQuote=true on Paste; it would be still possible to paste with bAutoQuote=false via GuiMacro
  • Use strong quoting (single-quote) where only ' have to be weirdly-quoted: 'Here'\''s my test...'

@Maximus5 Maximus5 added this to To Do in ConEmu via automation May 27, 2018

@Maximus5 Maximus5 moved this from To Do to In progress in ConEmu May 27, 2018

Maximus5 added a commit that referenced this issue May 27, 2018

gh-1579: Changes in escaping rules on pasting POSIX paths (exclamatio…
…n `!` mark).

  * if path contains special characters, strong quoting (single-quote) is used
  * it's still possible to paste without quotation via GuiMacro

@Maximus5 Maximus5 moved this from In progress to Ready for Testing in ConEmu May 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment