Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

I've tested it. If I use "!P", the double quote is escaped correctly.
user564758

It's a problem with having a double quote in the string. Use the example to see the problem.

¬`¦!"£$%^&*()_+{}~[]#:@;'<>?,./|\
martin

I'm not sure I understand the problem.

user564758 wrote:

If i use just !P i get this result.

"¬`¦!"£$%^&*()_+{}~[]#:@;'<>?,./|\"

If you use just !P, you should get no quotes around the value. And actually, it makes little sense to use any placeholder without quotes.
user564758

Well thanks for considering it but there is still the bug/issue with double quotes that maybe should be treated separately.

For example this password cannot be used with "!P" as the double quote in the password breaks the way WinSCP handles quoting the string.

¬`¦!"£$%^&*()_+{}~[]#:@;'<>?,./|\


If i use just !P i get this result.

"¬`¦!"£$%^&*()_+{}~[]#:@;'<>?,./|\"


But as i mentioned this now breaks paths with spaces.

Can you please look into that as a potential bug?

Please see here to view how i am using it via a bash function

https://github.com/userdocs/LFTP4WIN-CORE/blob/master/system/scripts/functions.sh#L75-L93

That passes it to openssh.

https://github.com/userdocs/LFTP4WIN-CORE/blob/master/system/applications/winscp/winscp_openssh.WinSCPextension.sh

This is more functional than the kitty integration as it cannot handle this kind of password.
martin

OK, I will see, if more people ask for this.
user564758

I'll try to explain the problem and why have a fully encoded version of the expansions might be useful.

Let's say i have a remote path on Linux like this, it has both single and double quotes in the path.

/home/username/They she w/¬`!"£$%^&*()_+-={}~[]#:@;'<>?,.|\/Kispál és a Borz - 02 - Tökéletes Helyettes


Or a password like this:

¬`¦!"£$%^&*()_+-={}~[]#:@;'<>?,./|\


Or a local path like this:

F:\downloads\One the twar\¬`!£$%^&()_+-={}~[]#@;',\New folder


When "!/" is used with the above remote path I cannot pass this onto anther program as the double quotes cause a conflict. WinSCP will behave differently with this URL. for example, using my custom command via an extension - https://github.com/userdocs/LFTP4WIN-CORE/blob/master/system/applications/winscp/winscp_lftp.WinSCPextension.sh

I can use this URL if i do not wrap the expansion in a double quote. WinSCP seems to escape this automatically but does not expand the result surrounded by quotes.

"%EXTENSION_PATH%" "!U" "!@" "!#" "!S" !/ "!\" "!P"


Will return this result ( with no double quotes at the start or end)

/home/username/They she w/¬`!"£$%^&*()_+-={}~[]#:@;'<>?,.|\/Kispál és a Borz - 02 - Tökéletes Helyettes


But if i now try this same unquoted expansion with a more basic path:

/home/username/They she w/


Whatever checks WinSCP has in place to escape the complex URL seems to miss this and i get result like this with no double quotes surrounded the result:

/home/username/They


Where as this quoted command will return the correct simple path but break the complex path:

"%EXTENSION_PATH%" "!U" "!@" "!#" "!S" "!/" "!\" "!P"


You see the result is wrapped in double quotes:

"/home/username/They she w/"


So whilst this may highlight a potential bug in how and when WinSCP escapes what it really shows is how the solution is to provide an encoded version, for example.

With a password like this:

¬`¦!"£$%^&*()_+-={}~[]#:@;'<>?,./|\


I simply cannot pass this to bash in any way using this command as the expansion of !P breaks the script by having double quotes and the last character technically escaping any other quotes once expanded when using this command format.

"%EXTENSION_PATH%" "!U" "!@" "!#" "!S" "!/" "!\" "!P"


But if i do this instead to get the password from the session URL, where $4 is !S:

password="$(echo -e $(echo $(echo "$4" | cut -f3 -d":" | cut -f1 -d";") | sed 's/%/\\x/g'))"


I can now pass on and reuse the password in anyway i need and only decode it as and when required without any real problems.

Conclusion:

If WinSCP could provide a URL encoded or base64 encoded version of the key expansions:

"!U" "!@" "!#" "!S" "!/" "!\" "!P"