am boolean $isJavascriptEnabled * @return $this */ public function setIsJavascriptEnabled($isJavascriptEnabled) { $this->isJavascriptEnabled = $isJavascriptEnabled; return $this; } /** * @return boolean */ public function getIsJavascriptEnabled() { return $this->isJavascriptEnabled; } /** * @return boolean */ public function isJavascriptEnabled() { return $this->getIsJavascriptEnabled(); } /** * @param boolean $isPhpEnabled * @return $this */ public function setIsPhpEnabled($isPhpEnabled) { $this->isPhpEnabled = $isPhpEnabled; return $this; } /** * @return boolean */ public function getIsPhpEnabled() { return $this->isPhpEnabled; } /** * @return boolean */ public function isPhpEnabled() { return $this->getIsPhpEnabled(); } /** * @param boolean $isRemoteEnabled * @return $this */ public function setIsRemoteEnabled($isRemoteEnabled) { $this->isRemoteEnabled = $isRemoteEnabled; return $this; } /** * @return boolean */ public function getIsRemoteEnabled() { return $this->isRemoteEnabled; } /** * @return boolean */ public function isRemoteEnabled() { return $this->getIsRemoteEnabled(); } /** * @param string $logOutputFile * @return $this */ public function setLogOutputFile($logOutputFile) { if (!is_callable($this->artifactPathValidation) || ($this->artifactPathValidation)($logOutputFile, "logOutputFile") === true) { $this->logOutputFile = $logOutputFile; } return $this; } /** * @return string */ public function getLogOutputFile() { return $this->logOutputFile; } /** * @param string $tempDir * @return $this */ public function setTempDir($tempDir) { if (!is_callable($this->artifactPathValidation) || ($this->artifactPathValidation)($tempDir, "tempDir") === true) { $this->tempDir = $tempDir; } return $this; } /** * @return string */ public function getTempDir() { return $this->tempDir; } /** * @param string $rootDir * @return $this */ public function setRootDir($rootDir) { if (!is_callable($this->artifactPathValidation) || ($this->artifactPathValidation)($rootDir, "rootDir") === true) { $this->rootDir = $rootDir; } return $this; } /** * @return string */ public function getRootDir() { return $this->rootDir; } /** * Sets the HTTP context * * @param resource|array $httpContext * @return $this */ public function setHttpContext($httpContext) { $this->httpContext = is_array($httpContext) ? stream_context_create($httpContext) : $httpContext; return $this; } /** * Returns the HTTP context * * @return resource */ public function getHttpContext() { return $this->httpContext; } public function validateArtifactPath(?string $path, string $option) { $parsed_uri = parse_url($path); if ($parsed_uri === false || (array_key_exists("scheme", $parsed_uri) && strtolower($parsed_uri["scheme"]) === "phar")) { return false; } return true; } public function validateLocalUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return [false, "The URI must not be empty."]; } $realfile = realpath(str_replace("file://", "", $uri)); $dirs = $this->chroot; $dirs[] = $this->rootDir; $chrootValid = false; foreach ($dirs as $chrootPath) { $chrootPath = realpath($chrootPath); if ($chrootPath !== false && strpos($realfile, $chrootPath) === 0) { $chrootValid = true; break; } } if ($chrootValid !== true) { return [false, "Permission denied. The file could not be found under the paths specified by Options::chroot."]; } if (!$realfile) { return [false, "File not found."]; } return [true, null]; } public function validatePharUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return [false, "The URI must not be empty."]; } $file = substr(substr($uri, 0, strpos($uri, ".phar") + 5), 7); return $this->validateLocalUri($file); } public function validateRemoteUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return [false, "The URI must not be empty."]; } if (!$this->isRemoteEnabled) { return [false, "Remote file requested, but remote file download is disabled."]; } return [true, null]; } }