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.

CommentFileSizeAuthor
ckeditor_link_file_double_encode.patch406 byteslucuhb

Comments

anrikun’s picture

Status: Active » Needs review

Thanks. 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.

hedley’s picture

I'm having the same issue in the 7 version as well

anrikun’s picture

Status: Needs review » Postponed (maintainer needs more info)

Actually 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!

hedley’s picture

I'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.

anrikun’s picture

@hedley: thanks for this info,
but please, could you list all the input format filters you use and their order too?

hedley’s picture

Here 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.

anrikun’s picture

Will try to test out removing all filters apart from CKEditor Link Filter and see what happens.

Yes please, thanks!

lucuhb’s picture

Here 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

anrikun’s picture

@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/files is your File system path as configured at admin/settings/file-system?
And /web your base path?

lucuhb’s picture

After 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 !

By the way, it is strange that your patch works as file paths should not reach the line you modified.

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 with sites/default/files/UHB/SUIO-IP/INFORMATION-ORIENTATION/toto%20%20titi%2C%20co ... .pdf" in my error_log

anrikun’s picture

@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!

lucuhb’s picture

I set filters with the same order as in #8

anrikun’s picture

Version: 6.x-2.1 » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Fixed

@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?

lucuhb’s picture

Seems to be OK for 6.x-2.x-dev. (but since I reorganize the filters I don't see the problem).

anrikun’s picture

Thanks lucuhb!
Waiting for hedley's confirmation about D7 now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hedley’s picture

Yes I can confirm I'm not getting any double encoding with relative path's now

anrikun’s picture

Thanks hedley!