From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe07.iad.POSTED!1d9d5bd3!not-for-mail From: David Thompson Newsgroups: comp.lang.ada Subject: Re: Open URLs Organization: Poor Message-ID: References: <1exooomj74fsx.1k5y7r1avujek$.dlg@40tude.net> X-Newsreader: Forte Agent 3.3/32.846 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Thu, 14 Jan 2010 08:32:25 UTC Date: Thu, 14 Jan 2010 03:32:43 -0500 Xref: g2news1.google.com comp.lang.ada:8738 Date: 2010-01-14T03:32:43-05:00 List-Id: On Sun, 3 Jan 2010 21:05:46 +0100, "Dmitry A. Kazakov" wrote: > On Sun, 3 Jan 2010 10:17:58 -0800 (PST), vlc wrote: > > > I am looking for a way to open URLs (like "file:///home/vlc/file") as > > files - as you would do with "Open (Handle, In_File, "/home/vlc/ > > file")". > > > > I could surely just remove the heading "file://", but this would still > > leave me with the problem of special characters like "file:///home/vlc/ > > name%20with%20spaces". > > The third / is a delimiter, theoretically there could be something between > file:// and /. The path might be followed by queries and fragments, see > here: > > http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax > Although one can just say queries aren't supported for resources that are actually files, since they don't make sense. (Although they might for something like a cryptographic FS where you must supply a password -- but then whether you should allow a password to be supplied by a potentially untrusted path is another issue.) Fragments are supposed to be implemented by the user agent (for the web, normally a browser); it's not clear to me whether the OP does or anyone else would want this below or above the proposed API. > > Does anybody know of a way to translate URLs to paths? > > You just parse it. What is the problem, except that the number of URI > schemes is huge. > Nontrivial but I wouldn't say huge -- and the number that make sense for files is pretty small. And the OP apparently only needs one. > Regarding replacing %20 with SP, I am not sure if this has to be done. You > have to dig the documents (RFC) to verify if % is indeed a defined > escape sequence, if there are any in the URI, I do not remember. Otherwise > it is a part of the file name to be passed further as is. > Yes % two-hex is in STD66=RFC3986 2, and %20=SP is even the example. Of course if there are codepoints not allowed in a pathname, like NUL on Unix, you can't support the corresponding escape %00 in a URI. And you need to decide some things like whether %2F is treated as a branch-character / which is similarly unsupportable, or as a branch delimiter in violation of the nominal URI semantics.