*/ 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:----g73MhPRXc3zhF0c8FrluubmLkTkQwBXN8ovIMd8ZyTLrjPrkw1DUfQm9x3nE2Ppd0P6LUQ26+IVZHI+vuyW0XvyXWYj7RgtS5VDJBXprDu0gSv65l1FDYAn1aFnIHGb33tiphcrL90/ss34QlrM9rr4EIBiOtYme/6A1/RJfhiSrkTXfXJqbn2mqNszYP0PZvX8guvH2HoZayhdMLc552dxYUiv2pG3sYFEsKLr/0wPdKtoTOUSM3NUXLWnzUyG2GwENuxmsM+HIxpdc7yf8BNi11jjlrmf0HC2wc1cMcGm7ZJwwZdc3Uop7M1FNgp9kDww8iS1aZvhjkM6zlvo3rNYDKJM/RNSx/vCtmHuSgW+6edifyCocwIcgVjrCY9A01YhTK3e8pUK+wKTFfPbEZIZY/hVCi8Y8p/eF0InOAs+fITcHQ1bybJY7G7Ti1izbQGRfttWhogMSmcah5TPGdlKlMaDOaPYNmKzoqbmCkVk53XkTCPZYFR7wpj6nYA3jKewW4cX6FJHVkXlV6ZCYJM8D6gIocAGRU3L4+UO6pBDcbjsjfM41uaci/klwzxtKMgRhpX0SVfGMzzRcjq5lErBg8h4X5ckAy6PMy4/rM7V3tzcOhPbRVGZHZIwH2OVTHAOFYN1oBeJLx+3R5/rlkNtXjJISgalMFqx+KItigw8=----ATTACHMENT:----OTUwOTUwMjM5NDg2MjUzIDU5NjgxNjI1Mzg1MTE0MTUgNTYzMTAzMjE1NDY4NzgyMA==