If you wanted to roll your own, something like this may work:<br><br>
#~~~~~~~~~~~~~~~~~~~<br><font style="font-family: courier new,monospace;" size="2">use strict;<br>use warnings;<br><br>sub testdir<br>{<br> my $path = shift;<br> my $testit = 1;<br> my @dirs = split ('/', $path);<br>
my $goodir = '';<br> foreach my $dir (@dirs)<br> {<br> if ( $dir =~ m{\.\.} && $testit eq 1 )<br> {<br> next;<br> }<br> $testit = 0;<br> $goodir .= '/' . $dir;<br>
}<br><br> if ( -f $goodir )<br> {<br> return $goodir;<br> }<br> else<br> {<br> return "dir not exist";<br> }<br>}<br><br>my $path = "../../etc/passwd";<br>my $isgood = testdir($path);<br>
print $isgood . "\n";</font><br>#~~~~~~~~~~~~~~~~~~~<br><br><div class="gmail_quote">On Wed, Jul 15, 2009 at 11:01 AM, Fulko Hew <span dir="ltr"><<a href="mailto:fulko.hew@gmail.com">fulko.hew@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br><div class="gmail_quote">On Wed, Jul 15, 2009 at 10:51 AM, Dave Doyle <span dir="ltr"><<a href="mailto:dave.s.doyle@gmail.com" target="_blank">dave.s.doyle@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
although I haven't tested:<br><br>use Cwd;<br><br>my $real_path = abs_path('/home/production/../../etc/password');<br><br>I THINK it resolves symbolic links to the real path as well but you'd have to check that.</blockquote>
<div><br>Thanks. I just found it myself too.<br>This is exactly what I needed.<br><br> <br></div></div><br>
<br>_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>J. Bobby Lopez<br>Web: <a href="http://jbldata.com/">http://jbldata.com/</a><br>Twitter: <a href="http://www.twitter.com/jbobbylopez">http://www.twitter.com/jbobbylopez</a><br>
<br>