Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def test_proxy_resource_parse(self):
@mock.patch('subprocess.Popen', autospec=True)
def test_open_page_in_browser(self, subprocess_open_mock, webbrowser_open_mock):
platform = sys.platform.lower()
open_page_in_browser('http://foo')
open_page_in_browser("http://foo")
if is_wsl():
subprocess_open_mock.assert_called_once_with(['powershell.exe', '-NoProfile',
'-Command', 'Start-Process "http://foo"'])
'-Command', 'Start-Process', '"http://foo"'])
elif platform == 'darwin':
subprocess_open_mock.assert_called_once_with(['open', 'http://foo'])
else:
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def open_page_in_browser(url):
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe
# Ampersand (&) should be quoted
return subprocess.Popen(
['powershell.exe', '-NoProfile', '-Command', 'Start-Process "{}"'.format(url)]).wait()
['powershell.exe', '-NoProfile', '-Command', 'Start-Process', url]).wait()
Copy link
Member

@notyashhh notyashhh Mar 5, 2026

Choose a reason for hiding this comment

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

I ran this as a script & it looks like the pwsh script actually executes which is embedded in the url.

MALICIOUS_URL = 'https://example.com/$(Write-Output INJECTED)'
SAFE_URL = 'https://example.com/normal-page'

With Current code: https://example.com/INJECTED

With Your PR changes: https://example.com/INJECTED

With my fix: https://example.com/$(Write-Output INJECTED)

except OSError: # WSL might be too old # FileNotFoundError introduced in Python 3
pass
elif platform_name == 'darwin':
Expand Down