[dokuwiki] Re: Duplicate slash patch

Hello, Andreas

Friday, April 18, 2008, 12:58:59 AM you wrote:

>> This patch fixes getBaseURL function, producing 2 consecutive slashes
>> in the URL. Patch contains fix and test for it.

AG> Hmm your test uses 'http:/example.com/' as baseurl!? There's a missing
AG> second slash?

My test uses $conf['baseurl'] param in a form, i've reached the bug on
the production site. With the value above, getBaseURL produces
http://example.com//. That's a bug.

AG> Your preg_replace('!^/+!','',$dir); will remove every slash from $dir!?

This reg kills only the starting slashes, note ^ anchor on the start.

But proper one is !/+$! reg to kill trailing slashes from the host, i
forgot to add the following test.

function test11(){
    global $conf;
    $conf['basedir'] = '/dokuwiki';
    $conf['baseurl'] = 'http:/example.com';
    $conf['canonical'] = 1;

    $this->assertEqual(getBaseURL(),'http:/example.com/dokuwiki/');
}

Attached patch includes the proper fix and the test above.

AG> Can you explain what the exact problem was?

DOKU_URL containing http://example.com//, http://example.com//wiki/
breaks compressed CSS files, because compressor recognizes 2nd
duplicate slash as a comment. I prefer to fix invalid url at first.


-- 
Best regards,
 Ilya                          mailto:ilya@xxxxxxxxxxx

Other related posts: