function FileTransfer::sanitizePath

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

Changes backslashes to slashes, also removes a trailing slash.

Parameters

string $path:

Return value

string

4 calls to FileTransfer::sanitizePath()
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::fixRemotePath in includes/filetransfer/filetransfer.inc
Returns a modified path suitable for passing to the server. If a path is a windows path, makes it POSIX compliant by removing the drive letter. If $this->chroot has a value, it is stripped from the path to allow for chroot'd filetransfer systems.

File

includes/filetransfer/filetransfer.inc, line 196

Class

FileTransfer

Code

function sanitizePath($path) {
    $path = str_replace('\\', '/', $path);
    // Windows path sanitization.
    if (substr($path, -1) == '/') {
        $path = substr($path, 0, -1);
    }
    return $path;
}

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