diff options
Diffstat (limited to 'includes/file.inc')
-rw-r--r-- | includes/file.inc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/includes/file.inc b/includes/file.inc index 73d513703..08bbbfdd5 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -85,9 +85,7 @@ define('FILE_STATUS_PERMANENT', 1); function file_create_url($path) { // Strip file_directory_path from $path. We only include relative paths in // URLs. - if (strpos($path, file_directory_path() . '/') === 0) { - $path = trim(substr($path, strlen(file_directory_path())), '\\/'); - } + $path = file_directory_strip($path); switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { case FILE_DOWNLOADS_PUBLIC: return $GLOBALS['base_url'] . '/' . file_directory_path() . '/' . str_replace('\\', '/', $path); @@ -1501,6 +1499,23 @@ function file_directory_path() { } /** + * Remove a possible leading file directory path from the given path. + * + * @param $path + * Path to a file that may be in Drupal's files directory. + * @return + * String with Drupal's files directory removed from it. + */ +function file_directory_strip($path) { + // Strip file_directory_path from $path. We only include relative paths in + // URLs. + if (strpos($path, file_directory_path() . '/') === 0) { + $path = trim(substr($path, strlen(file_directory_path())), '\\/'); + } + return $path; +} + +/** * Determine the maximum file upload size by querying the PHP settings. * * @return |