Skip to content

Commit b9c9117

Browse files
committed
[io grant] Toss IO::Path.child-secure
We'll make .child be .child-secure around 6.d time instead. Discussion: https://irclog.perlgeek.de/perl6-dev/2017-04-17#i_14439386
1 parent 5639284 commit b9c9117

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

doc/Type/IO/Path.pod6

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -136,33 +136,11 @@ C<IO::Path>.
136136
137137
method child(IO::Path:D: Str() $childname --> IO::Path:D)
138138
139-
Alias for L«C<.add>|/routine/add». See also
140-
L«C<.child-secure>|/routine/child-secure»
141-
142-
=head2 method child-secure
143-
144-
method child-secure(IO::Path:D: Str() $childname --> IO::Path:D)
145-
146-
Same as L«C<.child>|/routine/child», except it will
147-
B«fully L<resolve|/routine/resolve>» the resultant path and check that it is in
148-
fact a child of the invocant. On success, returns the resultant path;
149-
L«fails|/routine/fail» with C<X::IO::Resolve> if the path could not be
150-
completely resolved or with C<X::IO::NotAChild> if the resultant path is not
151-
a child of the invocant.
152-
153-
B<Note:> since the path has to be fully resolved, the method can still fail
154-
with C<X::IO::Resolve> even for paths that would be child paths, if some of
155-
the directories do not exist yet. The last part of the path does not have to
156-
exist for the routine to succeed.
157-
158-
=for code :skip-test
159-
my $parent = 'foo'.IO.mkdir;
160-
say $parent.child-secure: 'bar'; # OUTPUT: «"foo/bar".IO␤»
161-
say $parent.child-secure: '../bar'; # Fails with X::IO::NotAChild
162-
say $parent.child-secure: 'bar/ber'; # Fails with X::IO::Resolve
163-
164-
$parent.child('bar').mkdir; # create 'bar' so the call below succeeds
165-
say $parent.child-secure: 'bar/ber'; # OUTPUT: «"foo/bar/ber".IO␤»
139+
Alias for L«C<.add>|/routine/add». B<NOTE:> C<.child> will be switched to
140+
secure version around 6.d release time, which will C<fail()> with non-child
141+
paths and is also slower, since it has to do more work. Use
142+
L«C<.add>|/routine/add» if your code does not need to guarantee the added
143+
path is in fact a child path.
166144
167145
=head2 method extension
168146

0 commit comments

Comments
 (0)