Opened 17 years ago

Closed 11 years ago

#641 closed Bug (wontfix)

Relative URL become absolute on copy & paste

Reported by: martinkronstad@… Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: SF Cc: Frederico Caldeira Knabben, rickroot@…, sierra303@…, piyo@…, gppl@…, cpill@…

Description

In Internet Explorer the relative paths set in the editor become absolute paths if you view source , view wyciwyg , view source.


Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=999792&group_id=75348&atid=543653

Change History (4)

comment:1 Changed 17 years ago by Martin Kou

Cc: Frederico Caldeira Knabben rickroot@… sierra303@… piyo@… gppl@… cpill@… added
Reporter: changed from Martin Kou to martinkronstad@…

One last post and I'll leave you alone.

It works properly in Firefox!


Moved from SF. Original poster: Anonymous

Version 1.1 had this in its release notes:

problem with relative links and images

like "/test/test.doc" has been solved. In prior versions, only with XHTML support enabled, the URL was changed to something like "http://www.mysite.xxx/test/test.doc" (The domain was automatically added). Now the XHTML cleaning procedure gets the URLs exactly how they are defined in the editor’s HTML.

Is there still an "XHTML cleaning procedure" in the current version?


Moved from SF. Original poster: fredck

Ok... the original one is preserved. The problem happens when copying and pasting the link.


Moved from SF. Original poster: fredck

It still does this in IE. Go to the demo at [www.fckeditor.net/demo]. Click "source". Type in something like <a href="\demo">Testing</a>. Click source again. Then copy the link. Then pasted the link. Click source again. You'll see <a href="http://www.fckeditor.net/demo">Testing</a>. This is not the desired result.


Moved from SF. Original poster: Anonymous

It has been fixed on version 2.0 RC2.


Moved from SF. Original poster: fredck

Actually the bug has been reopened.

The human readable source code is completelly available in the "_source" folder.


Moved from SF. Original poster: fredck

Why has this bug been closed?

It is NOT fixed in 2.0 RC1

<img src="custom/images/james-duke-quote.jpg">

gets turned into:

<img src="/admin/FCK20RC1/editor/custom/images/james-
duke-quote.jpg">

This is a pretty serious problem.

Also, These solutions are all nice but editing fckeditorcode_ie_1.js is nearly impossible because all the code is jumbled together, no comments, no white space, no carriage returns, etc... how am I supposed to deal with that?

The same problem doesn't seem to affect firefox. However, relative path images do not show up in the editor in firefox.

  • Rick

Moved from SF. Original poster: rickroot

The following solved it for me. It may help you as well:

fck_1_ie.js (Line 92):

FCK.CheckRelativeLinks=function(){
  for (var i=0;i<this.EditorDocument.links.length;i++){
    var e=this.EditorDocument.links[i];
    var RelativePath=FCK.BaseUrl+FCKConfig.BasePath;     

    if (e.href.startsWith(RelativePath))
e.href=e.href.remove(0,RelativePath.length);
  };
  
  for (var i=0;i<this.EditorDocument.images.length;i++){
    var e=this.EditorDocument.images[i];
    
    if (e.src.startsWith(RelativePath))
e.src=e.src.remove(0,RelativePath.length);
  };
};

dialog/js/fck_link.js (Line 24):

var FCKConfig = oEditor.FCKConfig ;

dialog/js/fck_link.js (Line 171):

function LoadSelection()
{
	if ( !oLink ) return ;

	var sType = 'url' ;

	// Get the actual Link href.
	var sHRef = oLink.getAttribute('href',2) + '' ;
	
	// Remove false link href for relative links in IE
    var RelativePath=FCK.BaseUrl+FCKConfig.BasePath;     
	
	if ( sHRef.startsWith( RelativePath ) )
		sHRef = sHRef.remove( 0, RelativePath.length ) ;
   [...]

Regards Maik Unruh


Moved from SF. Original poster: sierra303

These ideas will help you, fredck.

innerHTML makes all links absolute?

InnerHTML vertaalt naar absolute url


Moved from SF. Original poster: Anonymous

The real problem is that IE automatically change the URL "test.html" to "http://your-site/ [FCKeditorPath]/functions/fckeditor/test.html". So the best thing the editor can do is to strip out the "http://your-site/ [FCKeditorPath]" part or the URL.

I'll reopen the bug so I can work on it for the final version.

Best regards, FredCK


Moved from SF. Original poster: fredck

RC1 is great, but doesn't fix this bug completely:

It changes a href=test.html

to a href=/functions/fckeditor/test.html

But that isn't the right place because the editor isn't in the same path as the html file with the ditor on it...

If you could please give me a hint where i can find that in the code, i will fix it by myself for my needs.

Thanks


Moved from SF. Original poster: sierra303

Version 2.0 RC1 fixed it.


Moved from SF. Original poster: fredck

Hi!

I've done some debugging on this one and i have to tell you that you all are looking at the wrong places!

The code ist already wrong after the editor opens!

Do the following in IE: -write some text -mark text -insert relative link on marked text -Send Editor Form and view the html-code -> url is OK -reopen the editor with this html-code -mark link-text -open link-menu -> url is already wrong!

So the html-code gets already malformed while opening the editor. Don't know where the bug is, but PLEASE fix it fast. Its the last real critical Bug for me. I have just started to work with the FCKEditor and its great. I might be able to help with development in a few days when I'm a little more into the code...


Moved from SF. Original poster: sierra303

I have it set up to where you can add a page (enter a brand- new hyperlink) and later edit that same page - typical Content Admin tool. When I add a page, and feature new relative hyperlinks, Piyo and Alexander's code works. But, when I go back later to make an edit to the page, the hyperlinks are replaced with 127.0.0.1:8500/FCKeditor/editor/index.cfm?whatever. The FCKEditor path seems to be automatically including itself until it is manually updated to reflect the relative hyperlink via the editor. Strange, aye?

The code adjustment works for adding a brand new relative hyperlink, but not when retrieving an already existing relative hyperlink. If you have any further insight, please post. The previous solution is definitely a huge step in the right direction to solving this problem. Thanks Piyo and Alexander!


Moved from SF. Original poster: Anonymous

The patch by Alexander 'alshur' Shurkayev was almost right:

else if (sAttName == 'src' && sAttValue.search(location.host) 
!= -1) sAttValue = sAttValue.substr((location.protocol + "//" + 
location.host).length);

else if (sAttName == 'href' && sAttValue.search(location.host) 
!= -1) sAttValue = sAttValue.substr((location.protocol + "//" + 
location.host).length);

This deletes the "http://yourhost" part, but it leaves the "/fckeditor/editor/" part. You could just forcefully delete the latter like this:

else if (sAttName == 'src' && sAttValue.search(location.host) 
!= -1) sAttValue = sAttValue.substr((location.protocol + "//" + 
location.host+"/fckeditor/editor/").length);

else if (sAttName == 'href' && sAttValue.search(location.host) 
!= -1) sAttValue = sAttValue.substr((location.protocol + "//" + 
location.host+"/fckeditor/editor/").length);

This "/fckeditor/editor/" is probably coming from the this.BasePath defined int fckeditor.js. It would be better to deelete it genericly (use this.BasePath + "editor/" instead) but I don't know how.

Also remember to reload or if necessary, restart your browser to clear the JS caching.

Verified on Sleipnir 1.66 (IE-compatible)


Moved from SF. Original poster: piyo

I tried the two solutions here proposals but none of them worked... :(

It continues placing the absolute path when I switch between code mode and WYSIWYG mode... it places the fckeditor path (http://.../fckeditor/editor/...). What is problem?

Somebody has some solution?

Thanks.


Moved from SF. Original poster: Anonymous

SOLUTION for relative paths in SRC and HREF attributes for FCKEditor beta 2.

Open fckeditorcode_ie_1.js and replace the string:

if (sAttName=='style' && document.all) 
sAttValue=htmlNode.style.cssText;

to:

if ( sAttName == 'style' && document.all ) sAttValue = 
htmlNode.style.cssText ;


else if (sAttName == 'src' && sAttValue.search(location.host) 
!= -1) sAttValue = sAttValue.substr((location.protocol + "//" + 
location.host).length);


else if (sAttName == 'href' && sAttValue.search(location.host) 
!= -1) sAttValue = sAttValue.substr((location.protocol + "//" + 
location.host).length);

That's it!

Alexander 'alshur' Shurkayev


Moved from SF. Original poster: Anonymous

Here is some solution: it's need to add function below to fckeditorcode_gecko_x.js

FCK.InsertLink = function(url,text){
	var tLink = '<a href="' + url + '">' + text + '</a>';
	FCK.InsertHtml(tLink);
}
to fckeditorcode_ie_x.js

FCK.InsertLink = function(url,text){
	FCK.Focus();
	var oSel = FCKSelection.Delete();
	var tRng = oSel.createRange();
	tRng.pasteHTML(text);
	tRng.moveStart('character',-text.length);
	tRng.select();
	FCK.ExecuteNamedCommand('CreateLink', url);
};

Tested in Mozilla 1.7.3, IE 6.0


Moved from SF. Original poster: gppl

IDM_AUTOURLDETECT_MODE this is the main problem i thing. But i did not found solution how to set it OFF


Moved from SF. Original poster: Anonymous

Can confirm this problem. I've even tried editing the source to remove the domain and problem still persists.


Moved from SF. Original poster: cpill

comment:2 in reply to:  description Changed 17 years ago by Alexander

To fix this bug in the current version (2.4), go to fckxhtml.js, line 363, right befofe

node = FCKXHtml._AppendChildNodes( node, htmlNode, false ) ;

and add the following code:

//delete host in IE
		if ( FCKBrowserInfo.IsIE && (htmlNode.href.search(document.location.host) != -1))
		{
			htmlNode.href = htmlNode.href.substr( (document.location.protocol + '//' + document.location.host).length );
			FCKXHtml._AppendAttribute( node, 'href', htmlNode.href ) ;
		}

works fine :)

comment:3 Changed 16 years ago by Wojciech Olchawa

Keywords: Confirmed added

comment:4 Changed 11 years ago by Jakub Ś

Resolution: wontfix
Status: confirmedclosed

This is no longer a problem in CKEditor 3.x or 4.x

Please note however that there is also some IE feature/bug that breaks relative URLs http://dev.ckeditor.com/ticket/8022#comment:5

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy