Active
Project:
FileField Sources
Version:
7.x-1.7
Component:
Source: Remote URL
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2013 at 09:35 UTC
Updated:
24 Apr 2013 at 01:50 UTC
Hi, Thanks for such a nice module.
I have one problem in Remote URL attachment module.
When i have the filename with space i.e http://www.mysourcefiledomain.com/file name.docx at that time it doesn't allow to attatch the file.
Here there is space between file and name
It is working fine when there is no space between the words of file name http://www.mysourcefiledomain.com/filename.docx
Comments
Comment #1
joelrotelli commentedOne solution could be to allow spaces in the valid_url function but i'm not sure whether very secure
However, we can just allow spaces in the query on the filefield_source_remote_value function, but i'm not sure too whether a good way ?
Comment #2
mohit_aghera commentedBut we can not modify valid_url function as it is drupal core function. But how should i modify the code of valid_url function to allow the space
I will create my own function with modified code. Can you guide me how to modify code it so i can allow some space in url.
Comment #3
joelrotelli commentedYes we could make a patch for that but I don't think it's a good idea to allow spaces in URL
Comment #4
mohit_aghera commentedBut today while attaching the file many file contains the space in between the name, so how can we achieve it ? Do you have any idea.
Can we encode it using urlencode ?
Comment #5
joelrotelli commentedI have tried with urlencode but it's not working anymore
I have also tried by removing temporarly the valid_url function but when the extension is checked, it fails because of the space in the name...
Comment #6
quicksketchSo spaces in URLs are not allowed by the URL spec (see http://www.w3schools.com/tags/ref_urlencode.asp for a simple reference). A URL like
http://www.mysourcefiledomain.com/file name.docxshould actually behttp://www.mysourcefiledomain.com/file%20name.docx. Most browsers will accomodate for the spaces and convert them to URL-encoded entities for you.To make FileField Sources work with spaces, what would need to be done is before the value is attempted to be used, it should automatically adjust the URL to urlencode it before checking if it's a valid URL. However you can't just run urlencode() on the whole URL, otherwise things like the
://inhttp://get encoded also. We'd have to urlencode each individual part of the path. I think this would also need to detect if a URL was already URL encoded, otherwise if a valid, already-encoded URL was entered, we wouldn't want to double-encode it.Comment #6.0
quicksketchAdded link in the url