Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi FileField dev team.
i found a problem is :
i use filefield for a new content type
and upload is fine with file name is "SS#27086.pdf"
and file will be save mydomain.com/files/SS#27086.pdf
but when i download this file with http or open it on browser it shown me is not found
seem problem with "#" character,
so i think we do need replace "#" to "_" or "-"
how about that,
Toan
Comment | File | Size | Author |
---|---|---|---|
#14 | filefield-filefield_formatter.inc-1249486-14.patch | 720 bytes | mr.j |
#8 | filefield-remove_double_escaped_url-1249486-8.patch | 1.07 KB | dooug |
#3 | filefield_encode_url.patch | 788 bytes | quicksketch |
Comments
Comment #1
quicksketchInstall http://drupal.org/project/transliteration.
This is still a bug that the # sign isn't converted into URL entity though. So we'll leave this open as a bug until I have time to confirm the problem.
Comment #2
tabvn CreditAttribution: tabvn commentedYes, you are right, i have convert use url encode (urlencode) , but i think this is mistake in filefield theme funciton
i hope FileField Dev Team, fixs this in next version.
Toan
Comment #3
quicksketchThis patch fixes up this problem. Apparently when using public files you have to manually encode the URL, as Drupal just assumes that the URL is okay otherwise. Private files are already encoded just fine.
Comment #4
quicksketchComment #6
basic CreditAttribution: basic commentedThis change appears to have broken URLs containing spaces. I have a few sites where the URLs are now getting double encoded. For example:
http://bec.orvsd.org/sites/bec.orvsd.org/files/A.1%201.doc
becomes
http://bec.orvsd.org/sites/bec.orvsd.org/files/A.1%25201.doc
and http://bec.orvsd.org/sites/bec.orvsd.org/files/A.1%25201.doc results in the file not being accessible.
Commenting out / reverting this change fixes the problem for me. I am unsure how to fix this, using rawurlencode seems to break it more.
Comment #7
dooug CreditAttribution: dooug commentedI also experienced issues with the ampersand character being double escaped in the file url of the generic file display.
I did not revert the previous commit, but noticed that the code was calling
drupal_urlencode()
followed byfile_create_url($path)
, which callsurl()
which also callsdrupal_urlencode()
. So thedrupal_urlencode()
in the theme_filefield_file() is unnecessary.Attached is a patch that removes that function and worked for me to prevent the double escaped file urls.
Comment #8
dooug CreditAttribution: dooug commentedUpon further review and testing. I realized that my partially reverting the original patch from comment #3 wasn't a solution.
However, I did notice that the
theme_filefield_formatter_url_plain()
function does the similar file url encoding with:http://cgit.drupalcode.org/filefield/tree/filefield_formatter.inc?h=6.x-...
So, it makes sense to use that
field_file_urlencode_path()
function that is used elsewhere in the module, rather than the commited patch from comment #3.I tested this and confirmed it solves double escaped/encoded ampersands (&) and hashes (#). I've attached the patch.
Comment #9
dooug CreditAttribution: dooug commentedChanged issue title for clarification.
Comment #10
herved CreditAttribution: herved commentedHello,
I think this issue still needs work for I got double encoded urls after updating from Filefield 6.x-3.9 to 6.x-3.13.
Also I noticed other issues in the same file.
filefield\filefield_formatter.inc:68 :
filefield\filefield_formatter.inc:120 :
Hervé
Comment #11
pwolanin CreditAttribution: pwolanin as a volunteer commentedThe use of
drupal_urlencode()
looks clearly incorrect since for public files the output should never depend on whether we are using clean urls.Patch in #8 looks like a reasonable fix, but it would be helpful to have some test cases even for manual verification, or better yet add a set of tests to \FileFieldTestCase
Comment #13
pwolanin CreditAttribution: pwolanin as a volunteer commentedComment #14
mr.j CreditAttribution: mr.j as a volunteer commentedWhile installing this latest release my IDE flagged an error in theme_filefield_formatter_url_plain with an undeclared variable. Patch attached.