function FileTransfer::checkPath

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::checkPath()
  2. 8.9.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::checkPath()
  3. 10 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::checkPath()
  4. 11.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::checkPath()

Checks that the path is inside the jail and throws an exception if not.

Parameters

$path: A path to check against the jail.

6 calls to FileTransfer::checkPath()
FileTransfer::chmod in includes/filetransfer/filetransfer.inc
FileTransfer::copyDirectory in includes/filetransfer/filetransfer.inc
Copies a directory.
FileTransfer::copyFile in includes/filetransfer/filetransfer.inc
Copies a file.
FileTransfer::createDirectory in includes/filetransfer/filetransfer.inc
Creates a directory.
FileTransfer::removeDirectory in includes/filetransfer/filetransfer.inc
Removes a directory.

... See full list

File

includes/filetransfer/filetransfer.inc, line 159

Class

FileTransfer

Code

protected final function checkPath($path) {
    $full_jail = $this->chroot . $this->jail;
    $full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail)));
    $full_path = $this->fixRemotePath($full_path, FALSE);
    if ($full_jail !== $full_path) {
        throw new FileTransferException('@directory is outside of the @jail', NULL, array(
            '@directory' => $path,
            '@jail' => $this->jail,
        ));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.