This is the mail archive of the cygwin-apps-cvs mailing list for the cygwin-apps project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[setup - the official Cygwin setup program] branch master, updated. release_2.889-8-g9408563




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=9408563544dc3e8f17a1de13b33ea17aab630cd2

commit 9408563544dc3e8f17a1de13b33ea17aab630cd2
Author: SZAVAI Gyula <szgyg@ludens.elte.hu>
Date:   Wed Feb 28 12:51:24 2018 +0100

    Improve file:// URL handling
    
    As a repo URL, we're accepting:
    
    * raw windows paths (with both \ and /), e.g.
    
      c:\cygwin repo
      \\machine\share\cygwin repo
    
    * proper file: protocol URLs, e.g.
    
      file:///c:/cygwin%20repo
      file://machine/share/cygwin%20repo
    
    Most non-standard URLs accepted by the old code should work, too.
    Paths longer than 260 characters are not supported anymore.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=ccbb34d3a5471cb53ddf7ed28f108c43dd524b09

commit ccbb34d3a5471cb53ddf7ed28f108c43dd524b09
Author: SZAVAI Gyula <szgyg@ludens.elte.hu>
Date:   Wed Feb 28 12:51:23 2018 +0100

    NetIO: Remove unused URL parsing code


Diff:
---
 netio.cc   |   84 +++++++++++++-----------------------------------------------
 netio.h    |   11 +------
 nio-ie5.cc |    3 +-
 3 files changed, 21 insertions(+), 77 deletions(-)

diff --git a/netio.cc b/netio.cc
index d60f119..512750c 100644
--- a/netio.cc
+++ b/netio.cc
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <shlwapi.h>
+
 #include "resource.h"
 #include "state.h"
 #include "msg.h"
@@ -42,70 +44,6 @@ char *NetIO::net_proxy_passwd;
 char *NetIO::net_ftp_user;
 char *NetIO::net_ftp_passwd;
 
-NetIO::NetIO (char const *Purl)
-{
-  set_url (Purl);
-}
-
-NetIO::~NetIO ()
-{
-  if (url)
-    delete[] url;
-  if (proto)
-    delete[] proto;
-  if (host)
-    delete[] host;
-  if (path)
-    delete[] path;
-}
-
-void
-NetIO::set_url (char const *Purl)
-{
-  char *bp, *ep, c;
-
-  file_size = 0;
-  url = new char[strlen (Purl) + 1];
-  strcpy (url, Purl);
-  proto = 0;
-  host = 0;
-  port = 0;
-  path = 0;
-
-  bp = url;
-  ep = strstr (bp, "://");
-  if (!ep)
-    {
-      path = strdup (url);
-      return;
-    }
-
-  *ep = 0;
-  proto = new char [strlen (bp)+1];
-  strcpy (proto, bp);
-  *ep = ':';
-  bp = ep + 3;
-
-  ep = bp + strcspn (bp, ":/");
-  c = *ep;
-  *ep = 0;
-  host = new char [strlen (bp) + 1];
-  strcpy (host, bp);
-  *ep = c;
-
-  if (*ep == ':')
-    {
-      port = atoi (ep + 1);
-      ep = strchr (ep, '/');
-    }
-
-  if (*ep)
-    {
-      path = new char [strlen (ep)+1];
-      strcpy (path, ep);
-    }
-}
-
 int
 NetIO::ok ()
 {
@@ -136,11 +74,25 @@ NetIO::open (char const *url, bool cachable)
   else if (strncmp (url, "ftps://", 7) == 0)
     proto = ftps;
   else if (strncmp (url, "file://", 7) == 0)
-    proto = file;
+    {
+      proto = file;
+
+      // WinInet expects a 'legacy' file:// URL
+      // (i.e. a windows path with "file://" prepended)
+      // https://blogs.msdn.microsoft.com/freeassociations/2005/05/19/the-bizarre-and-unhappy-story-of-file-urls/
+      char path[MAX_PATH];
+      DWORD len = MAX_PATH;
+      if (S_OK == PathCreateFromUrl(url, path, &len, 0))
+        {
+          file_url = std::string("file://") + path;
+          url = file_url.c_str();
+        }
+    }
   else
+    // treat everything else as a windows path
     {
       proto = file;
-      file_url = (std::string("file://") + url);
+      file_url = std::string("file://") + url;
       url = file_url.c_str();
     }
 
diff --git a/netio.h b/netio.h
index 7b7d13f..6d0f044 100644
--- a/netio.h
+++ b/netio.h
@@ -24,8 +24,6 @@
 class NetIO
 {
 protected:
-  NetIO (char const *url);
-  void set_url (char const *url);
   BOOL ftp_auth;
 
   static char *net_user;
@@ -39,13 +37,8 @@ protected:
 public:
   /* if nonzero, this is the estimated total file size */
   int file_size;
-  /* broken down url FYI */
-  char *url;
-  char *proto;
-  char *host;
-  int port;
-  char *path;
-    virtual ~ NetIO ();
+
+  virtual ~ NetIO () {};
 
   /* The user calls this function to create a suitable accessor for
      the given URL.  It uses the network setup state in state.h.  If
diff --git a/nio-ie5.cc b/nio-ie5.cc
index 5c93894..6fada0f 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -114,8 +114,7 @@ DWORD Proxy::type (void) const
 static HINTERNET internet = 0;
 static Proxy last_proxy = Proxy(-1, "", -1);
 
-NetIO_IE5::NetIO_IE5 (char const *_url, bool cachable):
-NetIO (_url)
+NetIO_IE5::NetIO_IE5 (char const *url, bool cachable)
 {
   int resend = 0;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]