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

Issue1343 system_open_link E371 command not found Windows PowerShell and cmd #1396

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

jfishe
Copy link

@jfishe jfishe commented Mar 8, 2024

Steps for submitting a pull request:

  • ALL pull requests should be made against the dev branch!
  • Take a look at CONTRIBUTING.MD
  • Reference any related issues.
  • Provide a description of the proposed changes.
  • PRs must pass Vint tests and add new Vader tests as applicable.
  • Make sure to update the documentation in doc/vimwiki.txt if applicable,
    including the Changelog and Contributors sections.

Copy link
Member

@tinmarino tinmarino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the evalfunction

@@ -313,7 +313,7 @@ function! vimwiki#base#system_open_link(url) abort
else
let url = shellescape(a:url, 1)
endif
execute 'silent ! start "Title" /B ' . url
execute 'silent !start ' .. url
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the .. operator is synonym of the .
It would be nice to keep the same style for all Vimwiki code hence using the single dot ..

Please replace .. by .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:h expr5

For String concatenation ".." is preferred, since "." is ambiguous, it is also
used for |Dict| member access and floating point numbers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite Vim recommendation, I prefer keeping same style. At some point in the future, we may replace all . by ..

@@ -325,7 +325,7 @@ function! vimwiki#base#system_open_link(url) abort
else
let url = shellescape(a:url, 1)
endif
execute 'silent ! start ' . url
execute 'silent !start ' .. eval(url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the use of eval here is a bug. why to you evaluate a string like "http://www.example.com" ?
Plus it makes Vimwiki vulnerable to Remote Code Execution.

Please remote it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shellescape(a:url, 1) always outputs a single quote string, which powershell and pwsh reject. To remove eval(), I replaced shellescape with escape(a:url, '%|*#').

Fixed:~
* Issue #1343: Fix/Improvement: Following HTML link on Windows PowerShell
or cmd.exe was broken by change to |:!start| behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job for adding the release note.

@tinmarino
Copy link
Member

Hi @jfishe thank you for the PR. Please apply the comments:

  • Remove the eval function
  • Replace the double dot by single dot
  • Fix Vint automatic test

@tinmarino
Copy link
Member

Relates to #1343 and #1392

Change .. back to . string concatenation per
vimwiki#1396 (comment)

With set shell=pwsh.exe, shellescape(a:url, 1) always uses single quotes
regardless of set shellslash or noshellslash, contrary to `:h shellescape()`.
So use escape() similar to
https://github.com/dhruvasagar/vim-open-url/blob/66ed3caac15ed629ddc1740e416519fe3d71a4fb/autoload/open_url.vim#L2C3-L2C34
This eliminates eval() to remove the single quotes.
@jfishe jfishe requested a review from tinmarino March 17, 2024 22:27
@johannish
Copy link

I'm new to vimwiki, but I applied this change manually and I can confirm that it fixes #1392 for me (though Vim version is already version 9.0.2003).

Shell is cmd on Windows 11.

:VimwikiShowVersion

Version: 2024.01.24
Os: Windows
Vim: 900
Branch: dev
Revision: 69318e7
Date: 2024-03-16 14:23:28 -0300  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants