Exemplo n.º 1
0
 public function __construct($repositoryPath)
 {
     $pathString = $repositoryPath;
     if (!StringUtils::startsWith($pathString, '/')) {
         throw new \Exception('Repository Path must be absolute');
     }
     if (!StringUtils::endsWith($pathString, '/')) {
         $pathString .= '/';
     }
     $this->repositoryPath = DirectoryPath::parse($pathString);
 }
 protected function targetUrlExists($url)
 {
     try {
         $urlParts = parse_url($url);
         $urlPath = $urlParts['path'];
         $path = null;
         if (StringUtils::startsWith($urlPath, '/')) {
             /* Absolute paths won't work */
             return false;
         } else {
             $directoryPath = $this->path->getParentPath();
             $path = $directoryPath->appendPathString($urlPath);
         }
         $fileExists = $this->repository->exists($path);
         $this->linkedPaths[] = $path;
         return $fileExists;
     } catch (\Exception $e) {
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * @param Request $request
  * @param string  $path
  *
  * @throws AccessDeniedHttpException
  */
 protected function checkPreconditions(Request $request, $path)
 {
     if (StringUtils::startsWith($path, '/.git')) {
         throw new AccessDeniedHttpException();
     }
 }