Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2006-10-20 10:02:25

rmassart
New member
Registered: 2006-08-16
Posts: 3

Replacing basehref issues

I had the problem that the baseHref replacement was also replacing inline text. So if I have the following html snippet:

<a href="http://www.example.com/test">http://www.example.com/test</a>

After opening and saving this content in Xinha it got converted to:

<a href="/test">/test</a>

When really it should be:

<a href="/test">http://www.example.com/test</a>

ie the replacement was occurring on ALL matches in the content, not just those that are actually URLs.

I altered this by changing the following code in the fixRelativeLinks function:

    var baseRe = null
    if(typeof this.config.baseHref != 'undefined' && this.config.baseHref != null)
    {
      baseRe = new RegExp(this.config.baseHref.replace(HTMLArea.RE_Specials, '\\$1'), 'g');
    }
    else
    {
      baseRe = new RegExp(document.location.href.replace(/([^\/]*\/?)$/, '').replace(HTMLArea.RE_Specials, '\\$1'), 'g');
    }

    html = html.replace(baseRe, '');

to:
    var baseRe = null
    if(typeof this.config.baseHref != 'undefined' && this.config.baseHref != null)
    {
      baseRe = new RegExp("((href|src|background)=[\'\"])(" + this.config.baseHref.replace(HTMLArea.RE_Specials, '\\$1') + ")", 'g');
    }
    else
    {
      baseRe = new RegExp("((href|src|background)=[\'\"])(" + document.location.href.replace(/([^\/]*\/?)$/, '').replace(HTMLArea.RE_Specials, '\\$1') + ")", 'g');
    }

    html = html.replace(baseRe, '$1');

This is not a thorougly tested change and I don't know if this is something useful for others, but I thought I'd post it here anyway.

Offline

#2 2006-10-21 03:34:21

guillaumed
Xinha Administrator
From: Lyon, France
Registered: 2005-02-23
Posts: 85

Re: Replacing basehref issues

Usefull for me

Offline

#3 2006-10-21 07:24:24

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Replacing basehref issues

I have filed this as Ticket #870

Offline

Board footer

Powered by FluxBB