A file called "my image.jpg" in sites/files can be accessed with the following URLs in a browser (independent of Drupal or any mod_rewrite):
- htp://hostname/sites/files/my image.jpg
- htp://hostname/sites/files/my%20image.jpg
It can't be accessed at this URL:
- htp://hostname/sites/files/my+image.jpg
Apache gives a 404 and I think that's correct behaviour: plus symbols only signify encoded spaces in query strings, not in the main body of the URL.
Because l() calls url(), which calls drupal_urlencode() and thence the core PHP urlencode() function, then any links created to that file using l() will generate 404s.
Is this a case for using rawurlencode() instead, or adding extra string replacing to drupal_urlencode()?
Comments
Comment #1
xjessie007 commentedHave you solved your issue, please?
For reference, I just posted a similar one here:
http://drupal.org/node/910136
Comment #2
xjessie007 commentedI found the problem. This is caused by the patch located here http://drupal.org/files/issues/rawurlencode_0.patch and referenced here http://drupal.org/node/191116 (post #4).
The patch is correct, but it breaks url aliases that are stored with spaces in the database on the url_alias table (spaces are not correct). Urlencode changes spaces into + signs. Rawurlencode changes spaces to %20. I do not know how to fix the whole problem correctly, but to make it at least work, changing rawurlencode back to urlencode does the trick. Drupal 7 is said to handle + signs in URL in a better way (?). I hope this helps to others. It took me 3 days to find the cause of the issue.
My site: Maxi-Pedia.com
Comment #3
jp.stacey commentedHi xjessie007 - thanks for moving forward on this after so long. I think we ended up fixing it some other way but I can't remember now. I still think it's a problem, but I'm going to close this issue as a duplicate of #910136: Spaces throughout URLs being replaced by plus signs, not %20 as standard.