Any URL with special characters or spaces encoded do not upload properly. There is no error given but the file does not display once it is uploaded.

CommentFileSizeAuthor
#1 filefield_sources-516022.patch756 bytesaaronbauman

Comments

aaronbauman’s picture

Title: Files with %20 in the URL don't transfer correctly » Remote files with urlescaped characters don't transfer correctly
Status: Active » Needs review
StatusFileSize
new756 bytes

remote.inc creates files with url-escaped characters in the filename, for example "Picture%201.png"

However, when the browser tries to access the URL at "http://example.com/sites/default/files/Picture%201.png", the web server interprets this as a request for the file "Picture 1.png", which does not exist. The proper URL to access the file would have to itself be urlescaped, e.g. "http://example.com/sites/default/files/Picture%25201.png"

The solution is to rawurldecode() the filename before creating the local file:

--- sources/remote.inc	20 Sep 2009 20:57:20 -0000	1.2
+++ sources/remote.inc	3 Dec 2009 17:26:34 -0000
@@ -112,7 +112,7 @@ function filefield_source_remote_value($
     $field = content_fields($element['#field_name'], $element['#type_name']);
     $url = $item['filefield_remote']['url'];
     $pathinfo = pathinfo($url);
-    $filename = basename($url);
+    $filename = rawurldecode(basename($url));
     $filepath = file_create_filename($filename, file_directory_temp());
 
     if (empty($pathinfo['extension'])) {

This is a very similar issue to #454478: The selected file could not be used because the file does not exist in the database.
I wonder if this will crop again for other sources...

quicksketch’s picture

Status: Needs review » Fixed

Thanks committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.