/**
* Checks for snooping outside of the file system root.
*
* @param string $path A file system path to check.
*
* @return string A cleaned version of the path or exit on error.
*
* @throws \Exception
* @since 1.7.0
*/
public static function check($path)
{
if (strpos($path, '..') !== false) {
// Don't translate
throw new \Exception(sprintf('%s() - Use of relative paths not permitted', __METHOD__));
}
$path = self::clean($path);
if (JPATH_ROOT != '' && strpos($path, self::clean(JPATH_ROOT)) !== 0) {
throw new \Exception(sprintf('%1$s() - Snooping out of bounds @ %2$s', __METHOD__, self::removeRoot($path)));
}
return $path;
}