[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Improper ~/ expansion in file://

From: Klaus Weide
Subject: Re: lynx-dev Improper ~/ expansion in file://
Date: Sun, 22 Nov 1998 16:33:45 -0600 (CST)

On Fri, 20 Nov 1998, Ryan Hung wrote:

> On Fri, 20 Nov 1998, Klaus Weide wrote:
> >   The problem
> > should be solved where it is generated, which is where the /~ is replaced
> > by something else.
> Hmm, I see.  But where would "//" in a real pathname be appropriate?

A good question.  I don't know the real answer, but "\\" in Windows (which
probably would be translated into "//") has a specific meaning, and I seem
to recall that POSIX or some similar spec for Unix says something like
"a // at the beginning may have system-defined meaning". (Can anyone

Maybe it is only at the beginning of a pathname that "//" should be
preserved, but a function like LYTrimRelFromAbsPath() may get called
in many places and doesn't generally know if the string is a full
path.  So the safest thing may be to leave it alone once a "//" somehow
got into a path.  That is what lynx does, for the most part.  If a user
enters a path like that, he gets what he deserves (or maybe has a good

A complication is that URL paths and (at least Unux) filesystem paths
act differently w.r.t. "".  For files, a ".." steps back over multiple
slashes, but if I read the URL syntax correctly a ".." should step "in
between" the two slashes, there is a path segment between them that just
happens to be empty.  THe HTSimplify() function in Lynx refuses to step
back over "//" segments anyway, probably because it things that may be
the "//" occurring before the host in a URL.

[ ... ]
(I see the same things described by Ryan with 2.8.1rel2.)

> Hmm.  To clarify, what I'm getting with is that retrieving
> "file://localhost/~" or "file://localhost/~/" gets the correct home
> directory.  

Well what you are getting is actually the //home/username.  It just
happens that your OS regards that as the same as /home/username.

> However, the directory is listed as "/username" rather than
> "/home/username".  

An earlier version (around 2.7.1ac-0.91) shows this as

  Current directory is //home/username

as expected, even if I explicitly give "file://localhost//home/username".
(I have to give it explicitly because that version does not insert
an extra slash when expanding ~).

> When one does an "=" to look at the links there, the
> full path of the current page is listed as "//home/username".

Earlier version shows

   Name:  //home/lynxdev
    URL:  file://localhost//home/lynxdev

as expected.  So it seems there also has been a change in HTFile.c.


This change (untested) should prevent generation of the duplicate
slash from /~ in file URL, but doesn't do anything about the other

When /~ appears in something in "file syntax", i.e. a file without
"file:", it is normally handled in LYConvertToURL() in LYUtils.c
which doesn't introduce a double slash.


--- lynx2-8-1-orig/src/LYGetFile.c      Wed Oct 14 07:23:56 1998
+++ lynx2-8-1/src/LYGetFile.c   Sun Nov 22 16:24:13 1998
@@ -605,8 +605,10 @@
                            *cp1 = '\0';
                            cp1 += 2;
                            StrAllocCopy(temp, doc->address);
-                           LYAddHtmlSep(&temp);
-                           StrAllocCat(temp, wwwName(Home_Dir()));
+                           StrAllocCopy(cp, wwwName(Home_Dir()));
+                           if (!LYIsHtmlSep(cp))
+                               LYAddHtmlSep(&temp);
+                           StrAllocCat(temp, cp);
                            if ((cp2 = strchr(cp1, '/')) != NULL) {
                                StrAllocCat(temp, cp2);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]