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

Open www links without protocol #345

Closed
GoogleCodeExporter opened this issue Jun 4, 2015 · 3 comments
Closed

Open www links without protocol #345

GoogleCodeExporter opened this issue Jun 4, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Right-click a link that starts with www, not http
2. Click open (first option)


What is the expected output? What do you see instead?
I expect to see it opened in a browser client, like it works with the http 
protocol.
What I get is a ~20 second halt and this error message:
"A device attached to the system is not functioning."


What versions of mintty, Cygwin/MSYS, and Windows are you using?
mintty 1.1.1, Cygwin 1.7.15-1, Windows 7 64bit


Please provide any additional information below.
This occured with mintty 1.0.3 as well, but with a different error text.

Original issue reported on code.google.com by adrianlund on 10 Jul 2012 at 5:17

@GoogleCodeExporter
Copy link
Author

Mintty simply passes the string to Windows' ShellExecute() function, which 
performs the appropriate action on the file/address. A string like 
"www.foo.com" would be handled as a filename, and I actually do get "The system 
cannot find the file specified" as the error message.

There was no change here between 1.0.3 and 1.1.1. What was the address you were 
trying to open? Maybe it contained a Windows device name or something.

Special handling for "www" addresses without protocol could be added though. 
"ftp" too, I guess. Any others?

Original comment by andy.koppe on 16 Jul 2012 at 12:45

  • Changed title: Open www links without protocol
  • Changed state: Accepted
  • Added labels: Difficulty-Easy, Priority-Low, Type-Enhancement
  • Removed labels: Type-Defect

@rgburke
Copy link

rgburke commented Mar 7, 2016

A simple change to handle www addresses is:

diff --git a/src/winclip.c b/src/winclip.c
index 02b7785..137e184 100644
--- a/src/winclip.c
+++ b/src/winclip.c
@@ -52,7 +52,7 @@ win_open(wstring wpath)
   wstring p = wpath;
   while (iswalpha(*p)) p++;

-  if (*wpath == '\\' || *p == ':') {
+  if (*wpath == '\\' || *p == ':' || (wcslen(wpath) > 4 && wcsncmp(L"www.", wpath, 4) == 0)) {
     // Looks like it's a Windows path or URI
     shell_exec(wpath);
   }

This works for me when selecting www.google.co.uk and clicking Open.

A potential issue with this approach is that it would match files beggining with www. and would also miss addresses in upper case (e.g. WWW.GOOGLE.CO.UK). I don't know how likely it is that anyone would encounter these cases during normal use though.

Any thoughts on this?

@mintty
Copy link
Owner

mintty commented Mar 18, 2016

Included in 2.2.4, thank you.

@mintty mintty closed this as completed Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants