| Project: | Webform |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I have a client for which I use webform to allow people to apply for employment positions. when I allow users to attach their resume's to the form submission, everything works fine, until HR tries to access the resume file attachment via the emailed link or the link in the submission results for the form.
What is happening is that drupal is swapping spaces in the url for the encoded value of %20, but the line 586 of components/file.inc is setting the url value differently...
$file_url = file_create_url($info['dirname'] .'/'. rawurlencode($info['basename']))
Sets the value of a space in the url as %2520
When I remove the function call to rawurlencode I see that the code works much better.
can I submit a patch for this and get you guys to make the change into the code base?
Thanks,
Comments
#1
Here is the patch!
#2
Something tells me this is going to fix it in one place but break it in another. I bet this will make links in e-mails work (since they're plain text) but break it when the submission is viewed in a web browser.
#3
I have tested in both places... it was broken in both places. It seemed to me that the URL was being parsed twice or something.
If you have a better solution, I am totally amicable.
#4
Hm strange, I'm sure that urlencode() was put there for a reason. Perhaps a change in Drupal core has made it unnecessary.
#5
it was rawurlencode... and, I think that you may be right. My guess is that the function call "file_create_url" may have something to do with it...
#6
This call to rawurlencode() still exists in the 3.x version, though I'm still uncertain about this change. This won't be fixed in the 2.x version so I'm moving to the latest version.
#7
So it looks to me like we're doing the right thing if the file is a public file, but the double-encoding would only happen if you have the private file system enabled (admin/settings/file-system). Public files are not escaped but private files are run through url(), which ultimately calls drupal_encodeurl().
Considering many more users use public files than private files (and with good reason, private files are really, really slow), I think it's a good idea to hold-off on this change. If we can come up with a universal solution I'd be happy to hear it, but for now I think I'd recommend any of the following:
- Install the transliteration.module, which will make safe-names for your uploaded files and prevent this situation.
- Use public files instead of private files.
#8
I get this issue in emails (both plain and html) when using public files. Links to files are double-encoding spaces.
K
#9
Patch attached to fix this issue for users of private files only. Does not apply to 7.x-3.x.
#10
#11
Thanks Dave, committed finally.
#12
Automatically closed -- issue fixed for 2 weeks with no activity.
#13
#9 was perfect for me.
Thanks!