[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sbcl-devel
Subject:    [Sbcl-devel] Pathname part lack of syntax checking - bug or features?
From:       Douglas Katzman via Sbcl-devel <sbcl-devel () lists ! sourceforge ! net>
Date:       2022-07-31 22:14:27
Message-ID: CAOrNasyYbA8h9ACuBCFva17Aazfh9_xCnogVguKofyEFFUcmNg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I noticed that there is code out in the wild which performs
(make-pathname :directory `(:absolute "/var/tmp/"))
where the string contains slashes. CCL correctly errors because the
resulting pathname has no namestring, lacking an escape syntax whereby the
OS would treat an embedded slash as just an ordinary character and not a
delimiter.
I agree with this interpretation of the directory parts but I'm wondering
whether sufficiently many users get this wrong that it would be a
hindrance? It seems to work by accident in some lisps, not the least of the
reasons being that Unix traditionally permits slash characters where they
don't belong.  So //var/tmp//foo is the same as /var/tmp/foo by
OS convention.
Being stricter would have a slightly beneficial effect on merging in so far
as we would never produce "//a//b///c" by accident and fail to match a
canonical entry in the pathname intern table. In the example from CCL
below, notice that it attempts to show where it needs escaping, supposing
hypothetically that backslash is an escape character, and then of course
double-backslash because of string escaping.

? *(open (merge-pathnames "foo" (make-pathname :directory '(:absolute
"/var/tmp/"))) :direction :output)*

> Error: Filename "/\\/var\\/tmp\\//foo" contains illegal character #\/

> While executing: NATIVE-TRANSLATED-NAMESTRING, in process listener(1).

>

[Attachment #5 (text/html)]

<div dir="ltr">I noticed that there is code out in the wild which \
performs<div>(make-pathname :directory `(:absolute \
&quot;/var/tmp/&quot;))</div><div>where the string contains slashes. CCL correctly \
errors  because the resulting pathname has no namestring, lacking an escape syntax \
whereby  the OS would treat an embedded slash as just an ordinary character and not a \
delimiter.</div><div>I agree with this interpretation of the directory parts but \
I&#39;m wondering whether sufficiently many users get this wrong that it would be a \
hindrance? It seems to work by accident in some lisps, not the least of the reasons \
being that Unix traditionally permits slash characters where they don&#39;t belong.   \
So //var/tmp//foo is the same as /var/tmp/foo by OS  convention.</div><div>Being \
stricter would have a slightly beneficial effect on merging in so far as we would \
never produce &quot;//a//b///c&quot; by accident and fail to match a canonical entry \
in the pathname intern table. In the example from CCL below, notice that it attempts \
to show where it needs escaping, supposing hypothetically that backslash is an escape \
character, and then of course double-backslash because of string \
escaping.</div><div><br></div><div>





<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-as \
ian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(34,79,188)"><span \
class="gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(86,219,233)">? \
</span><span class="gmail-s2" \
style="font-variant-ligatures:no-common-ligatures"><b>(open (merge-pathnames \
&quot;foo&quot; (make-pathname :directory &#39;(:absolute &quot;/var/tmp/&quot;))) \
:direction :output)</b></span></p> <p class="gmail-p1" \
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stre \
tch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(34,79,188)"><span \
class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">&gt; Error: \
Filename &quot;/\\/var\\/tmp\\//foo&quot; contains illegal character #\/</span></p> \
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-as \
ian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(34,79,188)"><span \
class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">&gt; While \
executing: NATIVE-TRANSLATED-NAMESTRING, in process listener(1).</span></p> <p \
class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian \
:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(34,79,188)"><span \
class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">&gt;</span></p></div></div>






_______________________________________________
Sbcl-devel mailing list
Sbcl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic