summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-19 08:38:09 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-19 08:38:09 +0000
commitb2730e86d588bcf7fd0f036571014b75d1bc992f (patch)
tree4001412a51a8e34b981daba6828dea47cbc6d496 /includes
parentaf7cd743e9b9220d9909399f17703371cce9c404 (diff)
downloadbrdo-b2730e86d588bcf7fd0f036571014b75d1bc992f.tar.gz
brdo-b2730e86d588bcf7fd0f036571014b75d1bc992f.tar.bz2
#552066 by quicksketch and pwolanin: Fix bug with file_save_upload() and trailing slashes (with tests).
Diffstat (limited to 'includes')
-rw-r--r--includes/file.inc6
1 files changed, 5 insertions, 1 deletions
diff --git a/includes/file.inc b/includes/file.inc
index c0ce7c594..c0e68f52e 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -1067,7 +1067,7 @@ function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
* the status and use file_save() to save the changes.
*
* @param $source
- * A string specifying the filepath or URI of the upload field to save.
+ * A string specifying the filepath or URI of the uploaded file to save.
* @param $validators
* An optional, associative array of callback functions used to validate the
* file. See file_validate() for a full discussion of the array format.
@@ -1163,6 +1163,10 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
}
$file->source = $source;
+ // A URI may already have a trailing slash or look like "public://".
+ if (substr($destination, -1) != '/') {
+ $destination .= '/';
+ }
$file->destination = file_destination($destination . $file->filename, $replace);
// If file_destination() returns FALSE then $replace == FILE_EXISTS_ERROR and
// there's an existing file so we need to bail.