Skip to content

Incongruent behavior using cmd.exe to open URLs in some cases #4981

@tiagonapoli

Description

@tiagonapoli
  • Your Windows build number:

Microsoft Windows [version 10.0.18362.657]

  • What you're doing and what's happening:

Trying to open URLs via cmd.exe. There are some important differences on using it on win32 and WSL that I don't know how to overcome or if it's a bug or not. This problem has risen on a multiplatform javascript package to open URLs - https://github.com/sindresorhus/open and I have created an issue there because of this strange behavior of cmd.exe on WSL - sindresorhus/open#170:

// URL used on cmd.exe "https://sindresorhus.com/?abc=123^&def=456"
cmd.exe /s /c start "" "https://sindresorhus.com/?abc=123^&def=456" 
// WIN32 and WSL have different behaviors
// WIN32: Opens https://sindresorhus.com/?abc=123^&def=456
// WSL: Opens https://sindresorhus.com/?abc=123&def=456

// URL used on cmd.exe "https://sindresorhus.com/?abc=123&def=456 a"
cmd.exe /s /c start "" "https://sindresorhus.com/?abc=123&def=456 a"
// WIN32 and WSL have the same behavior and open https://sindresorhus.com/?abc=123&def=456%20a

// URL used on cmd.exe "https://sindresorhus.com/?abc=123^&def=456 a"
cmd.exe /s /c start "" "https://sindresorhus.com/?abc=123&def=456 a"
// WIN32 and WSL have the same behavior and open https://sindresorhus.com/?abc=123&def=456%20a

The only incongruence is when there are no spaces in the URL - in WSL it's necessary, for some reason, to escape & characters, while on win32 this is can't be done or it will open a different URL.

  • What's wrong / what should be happening instead:
    I was expecting the same behavior on WSL and win32 when running:
cmd.exe /s /c start "" "https://sindresorhus.com/?abc=123^&def=456" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions