Skip to content

Conversation

gnachman
Copy link

@gnachman gnachman commented May 12, 2019

In order for tilde expansion to work, a leading tilde and
any subsequent alphanumeric characters up to and including
the first slash must not be quoted.

This commit changes the quoting algorithm to forego quoting
the initial tilde (if present), any subsequent
alphanumerics, and the first slash. If the first character
is not a tilde then there is no change.

PATH       BEFORE       AFTER
~          '~'          ~
~user      '~user'      ~user
foo~bar    'foo~bar'    'foo~bar'
~/foo      '~/foo'      ~/'foo'
~ foo bar  '~ foo bar'  ~' foo bar'

See issue #349

In order for tilde expansion to work, a leading tilde and
any subsequent alphanumeric characters up to and including
the first slash must not be quoted.

This commit changes the quoting algorithm to forego quoting
the initial tilde (if present), any subsequent
alphanumerics, and the first slash. If the first character
is not a tilde then there is no change.

PATH       BEFORE       AFTER
~          '~'          ~
~user      '~user'      ~user
foo~bar    'foo~bar'    'foo~bar'
~/foo      '~/foo'      ~/'foo'
~ foo bar  '~ foo bar'  ~' foo bar'
@gnachman
Copy link
Author

Not sure why Travis is failing. It seems not to have updated after I fixed the lint problem on line 231.

@willco007
Copy link
Member

Just wondering if there was a reason you went with this approach over escaping whitespace and not using quotes at all which you talked about in the initial bug report.

@gnachman
Copy link
Author

After taking a closer look at the implementation, I became concerned about introducing bugs because it's not clear exactly which characters besides whitespace would need to be escaped. My understanding is that the paths are evaluated by the shell, which means characters like ! would need special escaping for tcsh. I doubt anyone knows all the rules.

@gnachman
Copy link
Author

Would you prefer I change it to use the method we talked about originally?

@willco007
Copy link
Member

This is fine with me, anyone using SCP have a chance to test this patch out?

gnachman added a commit to gnachman/iTerm2 that referenced this pull request Aug 13, 2019
@gnachman
Copy link
Author

gnachman/iTerm2@d1ccf10 applies this patch to the nightly build of iTerm2. I'll see if anyone hollers. I've tested it on my Ubuntu machine. Not sure how testing usually works on this project?

@tiennou
Copy link
Contributor

tiennou commented Aug 13, 2019

I'll humbly point to #243, which is waiting for a merge, but has the necessary infrastructure (or at least easier to use). And I'll gladly take care of any additional testcases, as long as they are green 😉. Right now I've only added things I'm sure of and/or have been able to write non-bogus testcases for (writing the harness is also somewhat a WIP). There's also a ci/more-testcases branch in my fork which has the "tentative" ones (sftp, agent, and scp).

@gnachman
Copy link
Author

@tiennou That's a big diff. If I merge that into my fork, how do I run the tests and where's the right place to add mine?

@tiennou
Copy link
Contributor

tiennou commented Aug 18, 2019

Here's a few "documentation" points, sorry for the terseness :

There should be a libssh2_clar executable built if you perform a "vanilla" cmake (the test suite is built by default).
The test list is maintained by tests/generate.py, which should automatically refresh the caches clar uses (I'm mentioning it because sometimes Xcode misses updates. YMMV using other generators).
A clar test suite is a .c file under tests/testcases/$system/$suite.c, and consists of two (optional) initialize & cleanup callbacks to perform shared setup, and then any number of void test_$system__$testname(void) functions.
The filesystem location is used to construct "specifiers", eg. tests/testcases/agent/crashy/local.c becomes agent::crashy::local. You can pass that as -sagent::crashy::local::broken_test_against_thing, to select a specific test function. Use -x to yank suites.
See tests/libssh2_clar.h for support helpers (mostly managing Docker and setting up sessions correctly so the trace gets dumped on failures).

I just noticed I have some rebasing to do (a test was added for agent forwarding), so I'm currently having to bring in some of the helpers added afterwards to be able to support the new test.

@stale
Copy link

stale bot commented Nov 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 16, 2019
@stale stale bot closed this Dec 7, 2019
@willco007 willco007 removed the stale label Dec 17, 2019
@willco007 willco007 reopened this May 11, 2020
@willco007
Copy link
Member

@gnachman Any reports on this PR after landing it in iTerm?

@stale
Copy link

stale bot commented Oct 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 1, 2020
@stale stale bot closed this Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants