X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; q=dns; s=default; b=Ge SM7BmEyBz5YLciEUL4fqvxG1FnU6aPmibUfmkNCPPNDLCEaVCQakXYeGY6pTWHte qN/kPjFv2dl9tJG8q759tY/ReMnaaipPftWx5A9IK2ttl9l06dJMwOmc9y7LBik/ jDw8deKUM5n5LXgMMl1R/MIxZOogWU63p+vTsLjYI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; s=default; bh=Qa3mz8v6 /UxlIcr/y6wFgKu3akE=; b=GywDHEf6ATIDD1w7Lx+MY+p2Lkp5Og5RpwIaMbXd N0xHGpFEJaNX4ZMWAzEylCzqsWZzC7ZyQbDMheaGV/dRvq8elkkO7l3hKCeqljBb j3tjnLd0EtaB1vJemwmj4dwomES0zbNOC7y+eu2TDOIWnpfJg4e9VtPtZ5QfNSkw shI= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.9 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f172.google.com MIME-Version: 1.0 X-Received: by 10.220.5.1 with SMTP id 1mr3569865vct.73.1407264153984; Tue, 05 Aug 2014 11:42:33 -0700 (PDT) In-Reply-To: References: Date: Tue, 5 Aug 2014 13:42:33 -0500 Message-ID: Subject: Re: [cygstart] optional double slash after scheme for file URIs From: James Nylen To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes ...but that doesn't handle UNC paths. It might be worth looking at how Chromium does this: https://github.com/scheib/chromium/blob/master/url/url_parse_file.cc On Tue, Aug 5, 2014 at 1:21 PM, James Nylen wrote: > Chrome and IE cope with these variants just fine: > > file:C:/Projects > file:/C:/Projects > file://C:/Projects > file:///C:/Projects > file:////C:/Projects > > IE doesn't like more than 4 slashes, but Chrome doesn't mind. > > Your patch appears to only cover 0 or 2 slashes. How about something > like this instead of checking for "//": > > // remove all slashes except the last one > while (strncmp(aPath, "//", 2) == 0) aPath++; > > // path /C:/Projects is invalid, want C:/Projects instead > if (*aPath == '/' && *(aPath + 2) == ':') aPath++; > > On Tue, Aug 5, 2014 at 1:02 PM, Juan Gabriel Ricart > wrote: >> Greetings, >> >> Below you may find a trivial patch for the cygstart program (a part of >> the cygutils package) for your review: >> >> --- cygstart.c.old 2014-08-05 15:37:49.021062800 +0000 >> +++ cygstart.c.new 2014-08-05 14:20:54.318820400 +0000 >> @@ -591,8 +591,12 @@ >> const wchar_t *pWinDir = NULL; >> int rc = 0; >> >> - if (strncmp (aPath, "file://", 7) == 0) >> - aPath += 7; >> + if (strncmp (aPath, "file:", 5) == 0) >> + { >> + aPath += 5; >> + if (strncmp (aPath, "//", 2) == 0) >> + aPath += 2; >> + } >> #ifdef __CYGWIN__ >> /* Convert file path from POSIX to Windows, unless it looks like a URL */ >> if (!strstr (aPath, "://") && strncmp (aPath, "mailto:", 7) != 0) >> >> It makes the double slash after the scheme optional for file URIs. So >> this error would not happen: >> >> $ cygstart file:/home/ricartj/page.htm >> Unable to start 'file:\home\ricartj\page.htm: The specified file was not found. >> >> The reasons for this are enumerated below: >> >> 1. Although RFC 1738 explicitly documents the double slash as >> mandatory for file URIs (see Section 5), a new working draft is being >> proposed: >> >> http://tools.ietf.org/html/draft-kerwin-file-scheme-10 >> >> which makes the double slash optional (see Section 2.2). >> >> 2. Many browsers already cope with file URIs that do not contain the >> double slash, I personally tested this with Firefox and Internet >> Explorer. It would be great if cygstart could work like this as well. >> >> Best regards, >> >> -- >> Juan Ricart >> >> -- >> Problem reports: http://cygwin.com/problems.html >> FAQ: http://cygwin.com/faq/ >> Documentation: http://cygwin.com/docs.html >> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >> -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple