unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
       [not found] ` <20190615033015.46910210EC@vcs0.savannah.gnu.org>
@ 2019-06-27 21:57   ` Ken Brown
  2019-06-27 22:30     ` Juanma Barranquero
  2019-06-27 23:48   ` Stefan Monnier
  1 sibling, 1 reply; 13+ messages in thread
From: Ken Brown @ 2019-06-27 21:57 UTC (permalink / raw)
  To: emacs-devel@gnu.org, Juanma Barranquero

On 6/14/2019 11:30 PM, Juanma Barranquero wrote:
> branch: emacs-26
> commit 7a8f22b00484e2c1a28b48767b8562c6b6e89e06
> Author: Juanma Barranquero <lekktu@gmail.com>
> Commit: Juanma Barranquero <lekktu@gmail.com>
> 
>      * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.

This change causes the test to fail on Cygwin.  I think the original "file://" 
is the correct prefix.  If concatenated with "/some/file", it yields the URL 
"file:///some/file".  Your version with "file:///" as the prefix yields 
"file:////some/file", which would refer to a local file "//some/file".

Posix says that the meaning of a path name starting with exactly two slashes is 
implementation-defined.  On Cygwin, it's interpreted as a UNC path name, 
referring to a file on a network.

Ken

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-27 21:57   ` [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file:// Ken Brown
@ 2019-06-27 22:30     ` Juanma Barranquero
  2019-06-27 23:37       ` Ken Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2019-06-27 22:30 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]

On Thu, Jun 27, 2019 at 11:57 PM Ken Brown <kbrown@cornell.edu> wrote:

> This change causes the test to fail on Cygwin.  I think the original
"file://"
> is the correct prefix.  If concatenated with "/some/file", it yields the
URL
> "file:///some/file".  Your version with "file:///" as the prefix yields
> "file:////some/file", which would refer to a local file "//some/file".

It's a long-standing issue. The standard says that two slashes are to be
followed by a hostname, Three slashes, if there's no hostname.

So, in fact, Posix apps should strip the initial slash of an absolute
pathname before concatenating it to file:///

https://tools.ietf.org/html/rfc8089

Appendix B.  Example URIs
>    The syntax in Section 2 is intended to support file URIs that take
>    the following forms:
>    Local files:
>    o  A traditional file URI for a local file with an empty authority.
>       This is the most common format in use today.  For example:
>       *  "file:///path/to/file"



https://en.wikipedia.org/wiki/File_URI_scheme#How_many_slashes?


* A valid file URI must therefore begin with either file:/path,
> file:///path or file://hostname/path.
> * file://path (i.e. two slashes, without a hostname) is never correct, but
> is often used.


The test, as it is now, works for the native Windows port and fails for the
Cygwin port. So to work on both, some special-casing will have to be done.

Note that file:/// is already used in several places in the sources.

> Posix says that the meaning of a path name starting with exactly two
slashes is
> implementation-defined.  On Cygwin, it's interpreted as a UNC path name,
> referring to a file on a network.

This is not about Posix pathnames, but RFC8089 URI schemes.

[-- Attachment #2: Type: text/html, Size: 2632 bytes --]

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-27 22:30     ` Juanma Barranquero
@ 2019-06-27 23:37       ` Ken Brown
  2019-06-28  1:22         ` Juanma Barranquero
  0 siblings, 1 reply; 13+ messages in thread
From: Ken Brown @ 2019-06-27 23:37 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel@gnu.org

On 6/27/2019 6:30 PM, Juanma Barranquero wrote:
> 
> On Thu, Jun 27, 2019 at 11:57 PM Ken Brown <kbrown@cornell.edu 
> <mailto:kbrown@cornell.edu>> wrote:
> 
>  > This change causes the test to fail on Cygwin.  I think the original "file://"
>  > is the correct prefix.  If concatenated with "/some/file", it yields the URL
>  > "file:///some/file".  Your version with "file:///" as the prefix yields
>  > "file:////some/file", which would refer to a local file "//some/file".
> 
> It's a long-standing issue. The standard says that two slashes are to be 
> followed by a hostname, Three slashes, if there's no hostname.
> 
> So, in fact, Posix apps should strip the initial slash of an absolute pathname 
> before concatenating it to file:///
> 
> https://tools.ietf.org/html/rfc8089
> 
>     Appendix B.  Example URIs
>         The syntax in Section 2 is intended to support file URIs that take
>         the following forms:
>         Local files:
>         o  A traditional file URI for a local file with an empty authority.
>            This is the most common format in use today.  For example:
>            *  "file:///path/to/file"

This is exactly what I said.  From the context, I think it's clear that the 
words "path", "to", and "file" don't contain slashes.

There are four examples in the RFC with four slashes, and in every case it's 
explicitly stated that the URI represents a UNC string.

Ken

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

* Re: emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
       [not found] ` <20190615033015.46910210EC@vcs0.savannah.gnu.org>
  2019-06-27 21:57   ` [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file:// Ken Brown
@ 2019-06-27 23:48   ` Stefan Monnier
  2019-06-28  1:25     ` Juanma Barranquero
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2019-06-27 23:48 UTC (permalink / raw)
  To: emacs-devel

> -                 (url-file (url-generic-parse-url (concat "file://" file))
> +                 (url-file (url-generic-parse-url (concat "file:///" file))

So based on this discussion, I guess what this means is that using
a plain `concat` can't be right: for Windows-style name "c:/foo/bar"
we should use `(concat "file:///" file)`, whereas for POSIX-style file
names "/foo/bar" we should use `(concat "file://" file)`.


        Stefan




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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-27 23:37       ` Ken Brown
@ 2019-06-28  1:22         ` Juanma Barranquero
  2019-06-28  3:13           ` Ken Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2019-06-28  1:22 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

On Fri, Jun 28, 2019 at 1:37 AM Ken Brown <kbrown@cornell.edu> wrote:

> This is exactly what I said.  From the context, I think it's clear that
the
> words "path", "to", and "file" don't contain slashes.

If "path" does not contain slashes (with which I agree), concatenating it
to file:/// (not file://) is the right thing to do.

Anyway, if the check fails on Cygwin, the only fix is special-casing the
test according to system-type. Feel free to do it. No idea whether ms-dos
and darwin work with file:/// or file:// or both.

[-- Attachment #2: Type: text/html, Size: 932 bytes --]

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

* Re: emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-27 23:48   ` Stefan Monnier
@ 2019-06-28  1:25     ` Juanma Barranquero
  0 siblings, 0 replies; 13+ messages in thread
From: Juanma Barranquero @ 2019-06-28  1:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

On Fri, Jun 28, 2019 at 1:49 AM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> So based on this discussion, I guess what this means is that using
> a plain `concat` can't be right: for Windows-style name "c:/foo/bar"
> we should use `(concat "file:///" file)`, whereas for POSIX-style file
> names "/foo/bar" we should use `(concat "file://" file)`.

Strictly speaking, I think POSIX /foo/bar pathnames should be stripped of
the initial slash and then concatenated...

...but yeah, you're right. We need to do different things.

[-- Attachment #2: Type: text/html, Size: 738 bytes --]

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28  1:22         ` Juanma Barranquero
@ 2019-06-28  3:13           ` Ken Brown
  2019-06-28  4:08             ` Juanma Barranquero
  0 siblings, 1 reply; 13+ messages in thread
From: Ken Brown @ 2019-06-28  3:13 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel@gnu.org

On 6/27/2019 9:22 PM, Juanma Barranquero wrote:
> 
> On Fri, Jun 28, 2019 at 1:37 AM Ken Brown <kbrown@cornell.edu 
> <mailto:kbrown@cornell.edu>> wrote:
> 
>  > This is exactly what I said.  From the context, I think it's clear that the
>  > words "path", "to", and "file" don't contain slashes.
> 
> If "path" does not contain slashes (with which I agree), concatenating it to 
> file:/// (not file://) is the right thing to do.

No, you're forgetting the context of the test.  After your change it became

   (concat "file:///" file)

Here FILE is an *absolute* file name, which means it starts with a slash on a 
Posix system.  So you end up with four slashes.  Concatenating with file:// is 
the right thing to do for a POSIX-style file name, as Stefan said (and as I said 
in my original message).

Ken

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28  3:13           ` Ken Brown
@ 2019-06-28  4:08             ` Juanma Barranquero
  2019-06-28 12:55               ` Ken Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2019-06-28  4:08 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel@gnu.org

The standard is not defined diferently for Posix and non-Posix
filenames. It says that the URI is file://[hostname]/path.

Some interpret it as if that means file://[hostname] + "/path", but
that is incorrect, or file://C:/my/path would be correct for a
Windows-style path (it is not).

It is defined so, for a //hostname/path, you extract hostname and path
(without the slashes) and put them in the corresponding slots of the
URI. For a /path, you extract the path, and put it into its slot (and
the hostname slot is empty).

Evidently, most implementations just use file:// and concatenate the
Posix filename, and it just works. That it breaks with Windows-style
paths shows that something isn't really right.

But anyway, it's a moot point. If you want to fix the test for Cygwin,
please do.



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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28  4:08             ` Juanma Barranquero
@ 2019-06-28 12:55               ` Ken Brown
  2019-06-28 13:00                 ` Juanma Barranquero
  0 siblings, 1 reply; 13+ messages in thread
From: Ken Brown @ 2019-06-28 12:55 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel@gnu.org

On 6/28/2019 12:08 AM, Juanma Barranquero wrote:
> It is defined so, for a //hostname/path, you extract hostname and path
> (without the slashes) and put them in the corresponding slots of the
> URI. For a /path, you extract the path, and put it into its slot (and
> the hostname slot is empty).

Fine.  I accept your interpretation.  But that is *not* what your patch does. 
Your patch (on POSIX systems) creates URIs of the form "file:////path".  If you 
insist on using (concat "file:///" file), then you need to strip the leading 
slash from FILE.

Ken

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28 12:55               ` Ken Brown
@ 2019-06-28 13:00                 ` Juanma Barranquero
  2019-06-28 13:17                   ` Ken Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2019-06-28 13:00 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

On Fri, Jun 28, 2019 at 2:55 PM Ken Brown <kbrown@cornell.edu> wrote:

> Your patch (on POSIX systems) creates URIs of the form "file:////path".
If you
> insist on using (concat "file:///" file), then you need to strip the
leading
> slash from FILE.

I don't really "insist" in anything. I want the test to work everywhere so
we can just go on ;-)

I'll amend it.

[-- Attachment #2: Type: text/html, Size: 563 bytes --]

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28 13:00                 ` Juanma Barranquero
@ 2019-06-28 13:17                   ` Ken Brown
  2019-06-28 13:23                     ` Juanma Barranquero
  0 siblings, 1 reply; 13+ messages in thread
From: Ken Brown @ 2019-06-28 13:17 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel@gnu.org

On 6/28/2019 9:00 AM, Juanma Barranquero wrote:
> On Fri, Jun 28, 2019 at 2:55 PM Ken Brown <kbrown@cornell.edu 
> <mailto:kbrown@cornell.edu>> wrote:
> 
>  > Your patch (on POSIX systems) creates URIs of the form "file:////path".  If you
>  > insist on using (concat "file:///" file), then you need to strip the leading
>  > slash from FILE.
> 
> I don't really "insist" in anything. I want the test to work everywhere so we 
> can just go on ;-)
> 
> I'll amend it.

Thank you.

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28 13:17                   ` Ken Brown
@ 2019-06-28 13:23                     ` Juanma Barranquero
  2019-06-28 17:27                       ` Ken Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2019-06-28 13:23 UTC (permalink / raw)
  To: Ken Brown; +Cc: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]

Done. Please check that it works on Cygwin.

[-- Attachment #2: Type: text/html, Size: 80 bytes --]

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

* Re: [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file://.
  2019-06-28 13:23                     ` Juanma Barranquero
@ 2019-06-28 17:27                       ` Ken Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Ken Brown @ 2019-06-28 17:27 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel@gnu.org

On 6/28/2019 9:23 AM, Juanma Barranquero wrote:
> Done. Please check that it works on Cygwin.

It does, thanks.

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

end of thread, other threads:[~2019-06-28 17:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20190615033014.12012.75126@vcs0.savannah.gnu.org>
     [not found] ` <20190615033015.46910210EC@vcs0.savannah.gnu.org>
2019-06-27 21:57   ` [Emacs-diffs] emacs-26 7a8f22b: * test/lisp/url/url-file-tests.el (url-file): Use file:///, not file:// Ken Brown
2019-06-27 22:30     ` Juanma Barranquero
2019-06-27 23:37       ` Ken Brown
2019-06-28  1:22         ` Juanma Barranquero
2019-06-28  3:13           ` Ken Brown
2019-06-28  4:08             ` Juanma Barranquero
2019-06-28 12:55               ` Ken Brown
2019-06-28 13:00                 ` Juanma Barranquero
2019-06-28 13:17                   ` Ken Brown
2019-06-28 13:23                     ` Juanma Barranquero
2019-06-28 17:27                       ` Ken Brown
2019-06-27 23:48   ` Stefan Monnier
2019-06-28  1:25     ` Juanma Barranquero

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).