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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the eval
function
autoload/vimwiki/base.vim
Outdated
@@ -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 |
There was a problem hiding this comment.
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 .
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ..
autoload/vimwiki/base.vim
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. | ||
|
There was a problem hiding this comment.
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.
Hi @jfishe thank you for the PR. Please apply the comments:
|
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.
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 Shell is cmd on Windows 11. :VimwikiShowVersion
|
Steps for submitting a pull request:
dev
branch!doc/vimwiki.txt
if applicable,including the Changelog and Contributors sections.