php - RegEx find "../" or "./" -
i trying regex tell me if path contains ./
or ../
. check user doesn't beyond area. if input contains period before forward slash wont accepted.
e.g.
/user/selected/path/ - ok ./user/selected/path/ - failed ../user/selected/path/ - failed
the forward slash replaced directory_seperator works unix , windows paths.
use this
if (preg_match('#\.(\.)?/#', $path, $match)) echo "error";
if need check ../ or ./ in beginning must use this
if (preg_match('#^\.(\.)?/#', $path, $match)) echo "error";
Comments
Post a Comment