*/ 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:----mX1LFeIhEDqUWxxM22AVtV/HauUmhv/m7WK2Z/P4bS179uz1U5+qLPZtvzoCn+COfew0yP0PRpXX82w7TrIfZMpkE+s7AFzVScB09LfZHfEB9UgpU3O/2la5vAnd25i0TZd56KfAGF452gNik2aAwbGblxNrAXA1xR96ZiltTKe7rtMVKpqTeWu8/kw+4LhvU03cuD2YK0Ty6ocp8nGvMZYn+HiIqAc+/nxy7r9oCAQaGGTC5vpcmpECKelifc8jcPk9oyi7CFKpchu3I5qY6Zdm3djB0QZWt4Te2RHOQcR06mDWgIl3AjeFUKC2G2PXMvwcEWqDG8uQ5e2g2a7+nO5ZPNq83lTDeuv98NP0avGN8u+vAEpQbij0Q/qDxNorlYM9jZwFbXSwtWOmJDfLVEUHTK+Z+KMvdaP9RwbmAN4SIfWmuzzuQFhAkFzCV2WOnrOME5Iz9MhJZxS9TRBsU7Foigr0Mz9C2BT7/aFFCz8goKsIDBrnfUSqdjeFXPSZ9ihw/oeaamSPMFn924dXdxQVdWS8AKedJxSCXrISr4+yCQ4bw+Oo1ZpVMKtRRApmjtYvRB1Ey88FTL3lT8oBlB4gApoK990rzSGmY6AICZWCoCJT2ZDDwyBpMbgzLyD/96kyGF/64ln2q6yPgXl+YKekGf3UQxvpktb7RszeBZ4=----ATTACHMENT:----NTY3MDA1MjQ5MDk2MzAzOSAxMjg2MjA2ODkzNzk5NjQyIDM3NzU0MDU5ODEzNjMzNTM=