Closed Bug 417199 Opened 16 years ago Closed 14 years ago

Erroneous conversion to relative paths when pasting links of the same domain to an editing area

Categories

(Core :: DOM: Editor, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 295930

People

(Reporter: m.kou, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12

When a user tries to paste a link whose href belongs to the same domain of the editing document's document.domain, and that document.open() and document.close() have been executed beforehand, then the href of the pasted link would be erroneously converted to relative path by Gecko.

Reproducible: Always

Steps to Reproduce:
1. Go to a website with a simple layout, like, http://www.google.com. The contents of the website do not matter as long as it won't block the DOM nodes we're going to add via JavaScript in the next steps.
2. With the URL bar or Firebug's JavaScript console, execute the following script to add an editable iframe to the end of the page:

f = document.body.appendChild(f.createElement('iframe'));
doc = f.contentWindow.document;
doc.open();
doc.close();
doc.designMode = 'on';

3. Fire up Microsoft Word or anything that can let you make a hyperlink and copy it. Make a hyperlink with the same domain as the website in point 1. (note: sites like Google might redirect you to a localized domain, so you might have to type something like http://www.google.com.hk/test at this point)
4. Copy the link you've made up in Microsoft Word and paste it to the editable iframe you've just created.
5. Examine the href attribute of the link you've just pasted in Firebug.
Actual Results:  
The href attribute is converted to a relative path. e.g. if I had typed http://www.google.com.hk/test in Microsoft Word before, I would have only href="test" left at step 5.

Expected Results:  
There should be no automatic conversion to relative paths. Midas should keep the same href I pasted.

The bug only occurs if document.open() and document.close() has been executed on the editable document. So it doesn't happen in the Midas online demo.

The issue was found to be the root cause of bug #193 of FCKeditor.
https://dev.fckeditor.net/ticket/193
When you have an image in your editable document, for example: 

<img title="Sonde" alt=
"Sonde" src="/uploaded/IMAGES/nasa_sonde.jpg" width="120" height="120" />

and you drag that image to another position within the document, the path of the
image is also modified: it is transformed into a relative URL, in my specific
case into: 

<img title="Sonde" alt=
"Sonde" src="../../uploaded/IMAGES/nasa_sonde.jpg" width="120" height="120" />

You can imagine the problems this causes when the document is saved and shown
on the website...

As Martin notes above, the problem occurs when the contents of the editable
iframe are written through document.open();write();close().
In my case this is the only way to do this, as we want to be able to edit not
a fraction of a document, but an *entire* document (including the <html> and
<head> tags that is).

Eagerly awaiting a fix for this ancient bug (this bug has been in Midas since
the very first time it was released).
This bug is probably the source of this issue in FCKeditor (CKeditor). The effects appear to be identical, anyway. 

http://www.fckeditor.net/forums/viewtopic.php?f=6&t=12409&p=32598
http://drupal.org/node/352704
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.