*/ class PathValidator { /** * Check if path looks valid and doesn't contain suspecious patterns. * The path must meet the following criteria: * * - It must be a string * - No NUL character * - No control characters between 0-20 * - No phar stream wrapper * - No php stream wrapper * - No glob stream wrapper * - Not empty path * * @throws \Exception In case the path doesn't meet all criteria */ public static function checkPath($path) { if (gettype($path) !== 'string') { throw new \Exception('File path must be string'); } if (strpos($path, chr(0)) !== false) { throw new \Exception('NUL character is not allowed in file path!'); } if (preg_match('#[\x{0}-\x{1f}]#', $path)) { // prevents line feed, new line, tab, charater return, tab, ets. throw new \Exception('Control characters #0-#20 not allowed in file path!'); } // Prevent phar stream wrappers (security threat) if (preg_match('#^phar://#', $path)) { throw new \Exception('phar stream wrappers are not allowed in file path'); } if (preg_match('#^(php|glob)://#', $path)) { throw new \Exception('php and glob stream wrappers are not allowed in file path'); } if (empty($path)) { throw new \Exception('File path is empty!'); } } /** * Check if path points to a regular file (and doesnt match suspecious patterns). * * @throws \Exception In case the path doesn't point to a regular file or matches suspecious patterns */ public static function checkFilePathIsRegularFile($path) { self::checkPath($path); if (!FileExists::fileExists($path)) { throw new \Exception('File does not exist'); } if (@is_dir($path)) { throw new \Exception('Expected a regular file, not a dir'); } } } __halt_compiler();----SIGNATURE:----dqBRKe6dcXlXuzHg7WaYj464Rx1UYSuse8pFbL8HvInWPEKQ1yiFzrqSCMQptPophrPfSntT0g0ZdtovGB91s0XEbngjgHD9n/RCwTDziDLtS54xBObHGDgfvOUqNbN5lemLOIQsn10O0fLStaY0sHeKnSxxnYRfRSYgFzG9cQdLIhTi2ESNhNx38s3EK4CzvRtW6kzHFWKybqn+FyJ6qXDJGcrR0xBqMbXaHMYapTnEJmeNeCBwaAMRYZF4MbUFX0oBYKtk15pdGiJpzQ0WLQvU263o6yBWULswgnPLXP47wmEdVDvS/Vn9pNUoXqVGSf+f9LpAl06eztfl8d6n5C384VMrbcR9tnTgYFH/dB7ER32uwhP0bJ1riaisRAiwVBOZ7p2x/o/TF3UT75Gb0RRSfv45RsozSGJATlpevqnTDvj+AoqnnR9aqF/7K5eN7RtG30kUdHpzgR2Mh+mZ6r2gJsZ76W3yZ82H2pne7yHhTTZEpJFZ5J7H5mG9oK40S1tPHCwNFT0ehqqa2d4X5YnZHI081Br/T8VB98Vmp3qXnGQ6jM4B16ru0aG1YUbKt9CfyE0w4fyupMGOy/6kCtPSwq1pc16wrhnuijZx2qZIxah1zXsoUbcSWjjXxiG188XCKMLHy4nK70Bs8BvbGbciF2jjhkgqaSk1TzihihM=----ATTACHMENT:----MTAyMDQ2MTkzMTM0NzU4NyAxNTQ1NDkzNjg4MjgzNTg1IDEzNzQ4MDc5MDk2ODI4MzA=