HTMLArea is re-writing urls

Found a bug? Tell us!!
Post Reply
RobinSummerhill
Posts: 4
Joined: Fri May 28, 2004 9:22 pm

HTMLArea is re-writing urls

Post by RobinSummerhill »

I've found a few problems when using the WYSIWYG HTMLArea control.

(My serendipity installation is in a subdirectory called 'serendipity' off my root)

If you enter a relative url in an <a> tag or <img> tag then a '/' is appended when you save it. If you enter a tag starting with 'serendipity'it is removed. e.g.:

<a href="uploads/test.jpg"> becomes <a href="/uploads/test.jpg">
<a href="/serendipity/uploads/test.jpg> becomes <a href="/uploads/test.jpg">

This means that adding images using the image browser results in a broken link.

My paths are set up correctly I think as everything else works ok (image upload, image management etc.)

Is the problem with my installation, HTMLArea, or S9Y?

Robin
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: HTMLArea is re-writing urls

Post by garvinhicking »

Please tell the version of s9y you're using.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
RobinSummerhill
Posts: 4
Joined: Fri May 28, 2004 9:22 pm

Serendipity 0.6-pl2

Post by RobinSummerhill »

Serendipity 0.6-pl2

I downloaded it last Friday
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Serendipity 0.6-pl2

Post by garvinhicking »

RobinSummerhill wrote:Serendipity 0.6-pl2

I downloaded it last Friday
Hm, okay. I guess you are using Internet Explorer? Because in Mozilla, it doesn't seem to be the case.

I remember once having corrected an issue with it, which caused some other troubles. I'll try to somehow find the time to correct this, but my schedule is a bit tight at the moment, so please stay tuned. :)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
RobinSummerhill
Posts: 4
Joined: Fri May 28, 2004 9:22 pm

Re: Serendipity 0.6-pl2

Post by RobinSummerhill »

garvinhicking wrote: Hm, okay. I guess you are using Internet Explorer? Because in Mozilla, it doesn't seem to be the case.
You're right. I've tried it with Netscape 7.1 and it works ok. Unfortunately the person I'm setting this up for uses Internet Explorer.

Robin
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Serendipity 0.6-pl2

Post by garvinhicking »

Hi Robin!

I just updated s9y's CVS with this new code; search for it in your htmlarea/htmlarea.js file and use this function instead:

Code: Select all

HTMLArea.prototype.stripBaseURL = function(string) {
        var baseurl = this.config.baseURL;
        // strip to last directory in case baseurl points to a file
        baseurl = baseurl.replace(/[^\/]+$/, '');
        _baseurl = baseurl;
        var basere = new RegExp(baseurl);
        string = string.replace(basere, this.config.baseURL);

        // strip host-part of URL which is added by MSIE to links relative to s
        baseurl = baseurl.replace(/^(https?:\/\/[^\/]+)(.*)$/, '$1');
        basere = new RegExp(baseurl);
        return string.replace(basere, baseurl);
};
At least it works with all the variants I tried. It will now always convert a relative link to an absolute one, but this should make no problem. And the benefit is, that it finally works. :)

Regards,
Garvin.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
RobinSummerhill
Posts: 4
Joined: Fri May 28, 2004 9:22 pm

Thanks

Post by RobinSummerhill »

That works fine now.

Thanks!
clear2go
Posts: 1
Joined: Sun Jun 13, 2004 11:45 pm

Post by clear2go »

This resolved my issue. Great that it was posted so clearly!
/Mike.
Post Reply