public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup 1/2] NetIO: Remove unused url parsing code
  2018-02-28 11:54 Remove legacy networking code, vol 2 SZAVAI Gyula
  2018-02-28 11:54 ` [PATCH setup 2/2] Improve file:// url handling SZAVAI Gyula
@ 2018-02-28 11:54 ` SZAVAI Gyula
  1 sibling, 0 replies; 5+ messages in thread
From: SZAVAI Gyula @ 2018-02-28 11:54 UTC (permalink / raw)
  To: cygwin-apps

---
 netio.cc   | 64 --------------------------------------------------------------
 netio.h    | 11 ++---------
 nio-ie5.cc |  3 +--
 3 files changed, 3 insertions(+), 75 deletions(-)

diff --git a/netio.cc b/netio.cc
index d60f119..c8982de 100644
--- a/netio.cc
+++ b/netio.cc
@@ -42,70 +42,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 ()
 {
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;
 
-- 
2.16.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH setup 2/2] Improve file:// url handling
  2018-02-28 11:54 Remove legacy networking code, vol 2 SZAVAI Gyula
@ 2018-02-28 11:54 ` SZAVAI Gyula
  2018-03-06 20:43   ` Jon Turney
  2018-02-28 11:54 ` [PATCH setup 1/2] NetIO: Remove unused url parsing code SZAVAI Gyula
  1 sibling, 1 reply; 5+ messages in thread
From: SZAVAI Gyula @ 2018-02-28 11:54 UTC (permalink / raw)
  To: cygwin-apps

As a repo url, we're accepting
* raw windows paths (with both \ and /)
  c:\cygwin repo
  \\machine\share\cygwin repo
* proper file: urls
  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.
---
 netio.cc | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/netio.cc b/netio.cc
index c8982de..1e784b1 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"
@@ -72,11 +74,24 @@ 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;
-  else
     {
       proto = file;
-      file_url = (std::string("file://") + url);
+
+      // WinInet expects a legacy file:// url
+      // (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;
       url = file_url.c_str();
     }
 
-- 
2.16.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Remove legacy networking code, vol 2
@ 2018-02-28 11:54 SZAVAI Gyula
  2018-02-28 11:54 ` [PATCH setup 2/2] Improve file:// url handling SZAVAI Gyula
  2018-02-28 11:54 ` [PATCH setup 1/2] NetIO: Remove unused url parsing code SZAVAI Gyula
  0 siblings, 2 replies; 5+ messages in thread
From: SZAVAI Gyula @ 2018-02-28 11:54 UTC (permalink / raw)
  To: cygwin-apps

[PATCH setup 1/2] NetIO: Remove unused url parsing code
[PATCH setup 2/2] Improve file:// url handling

 netio.cc   | 85 ++++++++++++++++++-------------------------------------------------------------------
 netio.h    | 11 ++---------
 nio-ie5.cc |  3 +--
 3 files changed, 21 insertions(+), 78 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH setup 2/2] Improve file:// url handling
  2018-02-28 11:54 ` [PATCH setup 2/2] Improve file:// url handling SZAVAI Gyula
@ 2018-03-06 20:43   ` Jon Turney
  2018-03-08 23:01     ` szgyg
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Turney @ 2018-03-06 20:43 UTC (permalink / raw)
  To: cygwin-apps; +Cc: SZAVAI Gyula

On 28/02/2018 11:51, SZAVAI Gyula wrote:
> As a repo url, we're accepting
> * raw windows paths (with both \ and /)
>    c:\cygwin repo
>    \\machine\share\cygwin repo
> * proper file: urls
>    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.

Great, thanks! I applied these patches.

> ---
>   netio.cc | 21 ++++++++++++++++++---
>   1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/netio.cc b/netio.cc
> index c8982de..1e784b1 100644
> --- a/netio.cc
> +++ b/netio.cc
> @@ -25,6 +25,8 @@
>   #include <stdlib.h>
>   #include <string.h>
>   
> +#include <Shlwapi.h>

This needs to be lower-case to compile on a case-sensitive system

(I think all w32api headers have lower-case names, notwithstanding MS's 
use of random case on a non-case-sensitive system)

> +
>   #include "resource.h"
>   #include "state.h"
>   #include "msg.h"
> @@ -72,11 +74,24 @@ 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;
> -  else
>       {
>         proto = file;
> -      file_url = (std::string("file://") + url);
> +
> +      // WinInet expects a legacy file:// url
> +      // (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();
> +        }

If PathCreateFromUrl fails (longer than PATH_MAX?), how intelligibly is 
that failure reported?

I suspect PathCreateFromUrlA is being called here.  What happens if 
there is a non-ascii character in the URL?

> +    }
> +  else     // treat everything else as a windows path
> +    {
> +      proto = file;
> +      file_url = std::string("file://") + url;
>         url = file_url.c_str();
>       }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH setup 2/2] Improve file:// url handling
  2018-03-06 20:43   ` Jon Turney
@ 2018-03-08 23:01     ` szgyg
  0 siblings, 0 replies; 5+ messages in thread
From: szgyg @ 2018-03-08 23:01 UTC (permalink / raw)
  To: cygwin-apps

On Tue, Mar 06, 2018 at 08:43:47PM +0000, Jon Turney wrote:
> On 28/02/2018 11:51, SZAVAI Gyula wrote:
> > [...]
> > Most non-standard urls accepted by the old code should work, too.
> > Paths longer than 260 characters are not supported anymore.
> 
> Great, thanks! I applied these patches.

Thanks.

> > @@ -72,11 +74,24 @@ 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;
> > -  else
> >       {
> >         proto = file;
> > -      file_url = (std::string("file://") + url);
> > +
> > +      // WinInet expects a legacy file:// url
> > +      // (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();
> > +        }
> 
> If PathCreateFromUrl fails (longer than PATH_MAX?), how intelligibly is that
> failure reported?

We get the "Unable to get setup from" messagebox and a
"connection error: 206" line in setup.log.

from https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382%28v=vs.85%29.aspx
206 (0xCE)   ERROR_FILENAME_EXCED_RANGE   The filename or extension is too long.


> I suspect PathCreateFromUrlA is being called here.  What happens if there is
> a non-ascii character in the URL?

It doesn't work, but it didn't work before my changes either.
(I've tried 2.889 with greek and chinese directory names, and it has failed.)

s

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-08 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 11:54 Remove legacy networking code, vol 2 SZAVAI Gyula
2018-02-28 11:54 ` [PATCH setup 2/2] Improve file:// url handling SZAVAI Gyula
2018-03-06 20:43   ` Jon Turney
2018-03-08 23:01     ` szgyg
2018-02-28 11:54 ` [PATCH setup 1/2] NetIO: Remove unused url parsing code SZAVAI Gyula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).