Search code examples
urlhyperlinktinymceabsolute

TinyMce troubles with hyperlink absolute url


I added tinyMce editor in my textarea input form. Unfortunately I have troubles sending hyperlink absolute urls.

I create dynamically the pages within a php CMS.

I can start tinyMce and I can send formatted text. When I try to add url, the final result is not the absoluted url I added, but it is preceded by another string url, as showed under:

//Input url: www.example.it, will process the following result:
//http://www.myDomain.example/folder/\"http://www.example.it\"

Because of that the final link doesn't work, even if in the tinyMce preview all seems to be good.

I followed the indications written in the official website FAQ to set the initial values:

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  relative_urls : false,
  remove_script_host : true,
  document_base_url : 'http://www.mydomain.example/folder/'
});

Solution

  • This is a really nasty gotcha. Notice the escaped quotes around the url you entered? You have magic_quotes set to on! I've just spent 2 hours tracking this bug down again so I figured I'd better document it on the site.

    Before saving the url to the database add:

    if  (get_magic_quotes_gpc())
        foreach ($row as &$value)
            $value = stripslashes($value);
    

    This will get rid of the escaped quotes and allow the browser to recognize an absolute url.