IO::Path::ChildSecure -Secure version of IO::Path.child
use IO::Path::ChildSecure; # good; you get IO::Path "foo".IO.&child-secure: 'meow'; # still good if 'foo/meow/foo/bar/../' exists; Failure if it doesn't "foo".IO.&child-secure: 'meow/foo/bar/../meow'; # bad; path isn't a child; you get Failure "foo".IO.&child-secure: '../';
In 6.c Perl 6 language,
secure, in a sense that it does no checks for whether the resultant path is
actually a child of the original path. It will be made secure in 6.d language,
but in the meantime you can use another method provided by this module!
"foo".IO.&child-secure: 'meow'; # good; you get IO::Path "foo".IO.&child-secure: 'meow/foo/bar/../meow'; # still good "foo".IO.&child-secure: '../'; # bad; path isn't a child; you get Failure child-secure "foo".IO, '../'; # can also use as a proper sub
Appends the given path chunk to the invocant and ensures the resultant path is, in fact, a child of the invocant, by accessing the filesystem and fully-resolving the path. The last chunk of the resultant path does not have to exist for the resolution to succeed.
failed to fully resolve the resultant path
X::IO::NotAChild if the resultant path is not a child of the invocant.
- Module requires Rakudo 2017.04 or newer and will
dieon earlier versions (more specifically, anything earlier than dev version v2017.03.292.g.0.b.5.a.41.ba.8)
- If you don't need to ensure secureness, use the much-faster core
Fork this module on GitHub: https://github.com/zoffixznet/perl6-IO-Path-ChildSecure
To report bugs or request features, please use https://github.com/zoffixznet/perl6-IO-Path-ChildSecure/issues
Zoffix Znet (http://perl6.party/)
You can use and distribute this module under the terms of the
The Artistic License 2.0. See the
LICENSE file included in this
distribution for complete details.
META6.json file of this distribution may be distributed and modified
without restrictions or attribution.