I just changed ckeditor_link version, from 6.x-1.2 to 6.x-2.1.
Links to files with special characters were then wrong, and I got a "not found page" error when user click on the file link.
Here is an exemple of file links I got after this update :
href="/web/sites/default/files/UHB/SUIO-IP/INFORMATION-ORIENTATION/Calendriers%2520de%2520s%25C3%25A9lection%2520et%2520modalit%25C3%25A9s%2520de%2520retrait%2520du%2520dossier%2520de%2520candidature%2520Masters%25202%2520de%2520psychologie%25202011-2012.pdf"
while it should be
href="/web/sites/default/files/UHB/SUIO-IP/INFORMATION-ORIENTATION/Calendriers%20de%20s%C3%A9lection%20et%20modalit%C3%A9s%20de%20retrait%20du%20dossier%20de%20candidature%20Masters%202%20de%20psychologie%202011-2012.pdf"
The problem is in the _ckeditor_link_filter_process function, that should decode url before send it to the ckeditor_link_url function.
Here is a patch that should solve the problem.
| Comment | File | Size | Author |
|---|---|---|---|
| ckeditor_link_file_double_encode.patch | 406 bytes | lucuhb |
Comments
Comment #1
anrikun commentedThanks. Will review ASAP!
FYI, the CKEditor Link plugin itself does not return non-transliterated paths (containing spaces or other characters) as suggestions.
But I agree that the CKEditor Link Filter should support existing paths even if they are not transliterated. So this is a bug indeed.
Comment #2
hedley commentedI'm having the same issue in the 7 version as well
Comment #3
anrikun commentedActually I can't reproduce the bug :-(
See the link at:
http://www.absyx.fr/test-page/test-2
Though it contains spaces, it is not broken.
@lucuhb, @hedley:
Could you please list *all* the filters you are using and their order.
Thanks!
Comment #4
hedley commentedI'm having the same issue but only for relative URL's (e.g /sites/default/files/file with spaces.pdf).
I'm using the Insert module to insert links to files, which adds replacements for special characters by itself (like %20 for spaces). I believe ckeditor_link module is then processing these links again (in my case it's turning %20 into %2520), I think it's the ckeditor_link_filter_process function which is doing this.
I think it's the preg_replace_callback which is doing this, but I'm not sure.
Comment #5
anrikun commented@hedley: thanks for this info,
but please, could you list all the input format filters you use and their order too?
Comment #6
hedley commentedHere are the input filters I'm using:
CKEditor Link Filter
Converts Media tags to Markup
Correct faulty and chopped off HTML
Empty paragraph filter
I've tried moving CKEditor Link Filter to the end but this doesn't help. Will try to test out removing all filters apart from CKEditor Link Filter and see what happens.
Comment #7
anrikun commentedYes please, thanks!
Comment #8
lucuhb commentedHere are filters I use, in order :
- URL filter
- Line break converter
- HTML corrector
- Hide email addresses using the SpamSpan technique
- Table alternate row filter
- CKEditor Link Filter
- HTML Purifier
Comment #9
anrikun commented@lucuhb:
Thanks.
If possible, could you disable all your filters except CKEditor Link Filter to see if there is any change.
By the way, it is strange that your patch works as file paths should not reach the line you modified.
So I guess I need to check something about this.
Can you confirm that
sites/default/filesis your File system path as configured atadmin/settings/file-system?And
/webyour base path?Comment #10
lucuhb commentedAfter disable successively ckeditor link filter and other filters, then enable and reorganize all, strangely the links to files are now OK on my test sites !
Thanks for your suggestion, of course I prefer not to add a patch on the module !
When I add this line
error_log(print_r($path,true));in the _ckeditor_link_filter_process() function (just before the return line), this function is called for file paths : I have lines withsites/default/files/UHB/SUIO-IP/INFORMATION-ORIENTATION/toto%20%20titi%2C%20co ... .pdf"in my error_logComment #11
anrikun commented@lucuhb: thank you for these reports.
When enabling and organizing filters again, did you change something or did you set exactly the same filters in the same order as at #8?
About the 2nd remark:
File paths are not expected to reach this part. I really have to check that!
Comment #12
lucuhb commentedI set filters with the same order as in #8
Comment #13
anrikun commented@lucuhb, hedley:
I have managed to reproduce the bug in D7.
It should now be fixed both in 7.x-2.x-dev and 6.x-2.x-dev.
Can you please confirm that it works as expected?
Comment #14
lucuhb commentedSeems to be OK for 6.x-2.x-dev. (but since I reorganize the filters I don't see the problem).
Comment #15
anrikun commentedThanks lucuhb!
Waiting for hedley's confirmation about D7 now.
Comment #17
hedley commentedYes I can confirm I'm not getting any double encoding with relative path's now
Comment #18
anrikun commentedThanks hedley!