Skip to content

Instantly share code, notes, and snippets.

@xdg

xdg/stdout Secret

Created February 23, 2017 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdg/0d4840a388db440ea232638fafbd66e9 to your computer and use it in GitHub Desktop.
Save xdg/0d4840a388db440ea232638fafbd66e9 to your computer and use it in GitHub Desktop.
diff --git a/dist/PathTools/lib/File/Spec.pm b/dist/PathTools/lib/File/Spec.pm
index 85ad17426c..72b6dcdef9 100644
--- a/dist/PathTools/lib/File/Spec.pm
+++ b/dist/PathTools/lib/File/Spec.pm
@@ -158,10 +158,13 @@ Returns a string representation of the parent directory.
=item no_upwards
-Given a list of file names, strip out those that refer to a parent
-directory. (Does not strip symlinks, only '.', '..', and equivalents.)
+Given a list of files in a directory (such as from C<readdir()>),
+strip out C<'.'> and C<'..'>.
- @paths = File::Spec->no_upwards( @paths );
+B<SECURITY NOTE:> This does NOT filter paths containing C<'..'>, like
+C<'../../../../etc/passwd'>, only literal matches to C<'.'> and C<'..'>.
+
+ @paths = File::Spec->no_upwards( readdir $dirhandle );
=item case_tolerant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment