#5218 closed Bug (fixed)
FF: Copy/paste of an image from same domain as CKeditor changes URL to relative URL
Reported by: | Omkar | Owned by: | Sa'ar Zac Elias |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 3.4.1 |
Component: | Core : Pasting | Version: | 3.1 |
Keywords: | HasPatch | Cc: | Vincent, sim@… |
Description
This issue occurs only in Firefox.
To reproduce:
- Go to an instance of CKEditor (eg http://drupal.ckeditor.com/)
- Add an image that uses the same domain (eg http://drupal.ckeditor.com/images/logo-ie.png)
- Check image properties in CKEditor to verify the full URL is listed
- Copy and paste the image
- Check image properties on the pasted image - URL has been modified
See attached screenshot.
My limited testing of a couple OSes and a few browsers shows that this issue occurs only in Firefox:
OS: OSX 10.6.2
Issue occurs in Firefox 3.5.8 (see screenshot) Issue does not occur in Chrome 5.0.307.9 beta Issue does not occur in Safari 4.0.4 (6531.21.10)
OS: Windows XP
Issue occurs in Firefox 3.5.8 Issue does not occur in IE 8.0.6001.18702
Attachments (4)
Change History (25)
Changed 15 years ago by
Attachment: | ckEditorFFBug.png added |
---|
comment:1 Changed 15 years ago by
Component: | General → Core : Pasting |
---|
OS: Linux
Issue occurs in Firefox 3.6 OK on Chromium 5.0.342.9 (43360)
OS: Windows XP
Issue occurs in Firefox 3.6 Issue occurs in IE 7
comment:3 Changed 15 years ago by
This bug also occurs on the latest nightly releases (to easily test it switch to source mode and enter "<img src="/test/test.png">" then switch back and cut-and-paste the resulting image - when you switch to source mode you will see it is now a relative url)
The issue is that firefox rewrites the image src attribute when you paste them, making them relative to the path to the editor (which may not be correct when you view the HTML elsewhere).
We have had success with the attached patch to htmldataprocessor which rewrites the src back to the _cke_saved_src
comment:4 Changed 15 years ago by
Cc: | sim@… added |
---|
The original patch unfortunately didn't fix it (I'm not sure why in my original testing I though it did), but I've uploaded a fixed version that does.
comment:5 Changed 15 years ago by
Keywords: | Confirmed added |
---|---|
Milestone: | → CKEditor 3.5 |
The fact is that, theoretically, the original _cke_saved_src attribute should be also pasted, and then used by the editor in the image dialog and when outputting data. I think the default data processing on pasting is instead overwritting the already available _cke_saved_src attribute, replacing it with the wrong src. This is the thing to be fixed.
comment:6 Changed 15 years ago by
That is exactly what's happening (I had to trace this through to fix it in our setup). I thought it was probably a bit ambitious for me to try to "fix" it without really knowing how it works, the attached patch is at least less invasive
FYI what I found was :
- the cke_saved_src is pasted correctly (my patch works by copying it back into the img src attribute on paste), but firefox has munged the src attribute
- When you paste the "paste" event handler in clipboard/plugin.js calls
editor.insertHtml( data[ 'html' ] );
which triggers an event "inserthtml" which runs CKEDITOR.htmlDataProcessor.toHtml in htmldataprocessor/plugin.js, which runs this:
function protectAttributes( html ) { return html.replace( protectAttributeRegex, '$& _cke_saved_$1' ); }
which overrides the cke_saved_src with the modified one firefox just pasted.
I assume though that its probably not appropriate though to just skip protectAttributes for pasted HTML (it wasn't necessarily pasted from within a ckeditor instance) - perhaps if it were modified not to overwrite existing cke_saved_src attributes in pasted code?
comment:7 Changed 15 years ago by
You found the root of the problem. My suggestion is changing the data processor so it'll create the cke_saved_src attribute only if it doesn't exist.
comment:8 Changed 15 years ago by
Another post which I believe might be related to this problem? Could serve as a good test case as well.
comment:9 Changed 15 years ago by
Keywords: | HasPatch added |
---|---|
Owner: | set to Tobiasz Cudnik |
Status: | confirmed → assigned |
Changed 15 years ago by
Attachment: | 5218.2.patch added |
---|
comment:10 Changed 15 years ago by
Owner: | changed from Tobiasz Cudnik to Sa'ar Zac Elias |
---|---|
Status: | assigned → review |
comment:11 Changed 14 years ago by
Status: | review → review_passed |
---|
comment:12 Changed 14 years ago by
Status: | review_passed → review_failed |
---|
There is no need to have the entire _cke_saved_src attribute check, including its value, in the findSavedSrcRegex regex. It can be simpler (less code) and faster, like /\s_cke_saved_src\s*=/
.
Changed 14 years ago by
Attachment: | 5218_3.patch added |
---|
comment:13 Changed 14 years ago by
Status: | review_failed → review |
---|
comment:15 Changed 14 years ago by
The same problem with "href" attribute (<a> tag). Tried to apply patch, but it doesn't help :(
comment:16 Changed 14 years ago by
Status: | review → review_passed |
---|
I'm giving R+ as ticket issue is fixed. If you're having similar issues with other attributes please open a new ticket for them.
comment:17 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed with [5878].
comment:20 Changed 14 years ago by
Unfortunately, I can still reproduce this problem on the nightly build using firefox 3.6.10
- Load http://nightly.ckeditor.com/5888/_samples/replacebyclass.html
- Click the insert image icon and insert "/test/fake.gif" (you can also just insert this in the source)
- Copy and paste the image
The url of the pasted image becomes <img src="../../test/fake.gif">
Screenshot of the URL being modified in Firefox 3.5.8