sindresorhus/opn

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Add an option to allow disabling ampersand escaping #74

MarshallOfSound posted onGitHub

We've found when launching files with a "&" in their filename this escaping breaks the launch. (Windows throws a could not find file error). This PR just adds an option to allow disabling the escaping 👍


@MarshallOfSound @sindresorhus I had test these targets on Windows 7:

target escape mode open result
G:\&b.docx no escape FAIL
G:\&b.docx escape by ^ SUCCESS
G:\a&b.docx no escape FAIL
G:\a&b.docx escape by ^ SUCCESS
G:\a&b c.docx no escape SUCCESS
G:\a&b c.docx escape by ^ FAIL
G:\a&b c.docx using " " wraping space only FAIL
G:\a&b c.docx using " " wraping target FAIL
G:\a&b\c.docx no escape FAIL
G:\a&b\c.docx escape by ^ SUCCESS
G:\a b\c.docx no escape SUCCESS
G:\a b\c.docx escape by ^ FAIL
https://bing.com/search?q=a&b^c no escape FAIL (open wrong url)
https://bing.com/search?q=a&b^c escape by ^ SUCCESS (open url q=a&b^c)
https://bing.com/search?q=a&b^c using " " wraping target FAIL
https://bing.com/search?q=a b^c no escape SUCCESS (open url q=a%20b^c)
https://bing.com/search?q=a b^c escape by ^ FAIL (open wrong url)
https://bing.com/search?q=a b^c using " " wraping target FAIL
file:///G:/a&b.docx no escape FAIL
file:///G:/a&b.docx escape by ^ SUCCESS
file:///G:/a&b.docx using " " wraping target FAIL
file:///G:/a b.docx no escape SUCCESS
file:///G:/a b.docx escape by ^ FAIL
file:///G:/a b.docx using " " wraping target FAIL

Finally, I got 3 conclusions:

  • If contains space, DO NOT escape;
  • otherwise, DO escape.
  • No matter target is URL, or file path.
posted by baoti almost 7 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests