If in the UI configuration for a field you set a directory for File Field Path that ends with a SLASH such as this one:
paper/[node:nid]/field_version_word/
Paths are generated all over with a double slash, generating random errors in different places, depending on you webserver having a double slash in a path will simply brake access to the file or end up with file permissions errors:
://paper/[node:nid]/field_version_word//xxxxxx.docx
We can blame the user for this, or simply take care of that slash in
filefield_paths_process_string($value, $data, $settings = array())
inside
\sites\all\modules\filefield_paths\modules\filefield_paths.inc
Adding the following line just at the start of the method:
$value = rtrim($value,"/");
I'll be preparing a proper patch in the following days.
And possibly, add some validation in the UI so that the path is checked for "correctness" (I don't know if this is already done, and if it is, add verification for slash at end of directory).
Comment | File | Size | Author |
---|---|---|---|
#2 | 2211665-remove-trailing-slashes.patch | 465 bytes | david_garcia |
Comments
Comment #1
david_garcia CreditAttribution: david_garcia commentedComment #2
david_garcia CreditAttribution: david_garcia commentedRerolled against correct branch.
Comment #3
neRok CreditAttribution: neRok commentedThank you for identifying this issue, which I can confirm does exist. I am not sure your solution is the best though. It would probably be better to check for the slash during the form fields element_validate, as per core (see below).
However, the same check may also be required during
filefield_paths_process_string
, in case a token adds some slashes.Comment #4
Deciphered CreditAttribution: Deciphered commentedI've implemented the validation callback as per core and it fixes the problem nicely.
I haven't yet dealt with
filefield_paths_process_string
because I believe there is another issue debating the correct approach to take.
Committed and fixed.
Comment #5
david_garcia CreditAttribution: david_garcia commentedThank you @Dechipered! Can you tell us what issue is that?
Comment #6
Deciphered CreditAttribution: Deciphered commented#1942720: Provide option to allow removing slashes (/) from tokens