Arbit - project tracking

Arbit - project tracking

#129: BaseUrl generation not compatible with windows OS

Issue revisions

  • new by dr4g at 2010-J-28 2:15
  • assigned by Jordi Boggiano at 2010-J-28 8:25
  • closed by Jordi Boggiano at 2010-J-28 8:30
Type bug bug
State closed closed
Priority blocker blocker
Resolution fixed fixed
Assigned to Jordi Boggiano
Scheduled for 0.3-alpha
Affected versions 0.2-alpha
Affected components Core
Last change Thursday 28 January 2010 08:30:46 UTC by Jordi Boggiano
Short description
-----------------
All basepaths were being prefixed with \/
This means it was not able to load the project or any stylesheets.
For example http://localhost\/styles/screen.css
...

Environment
-----------
Windows OS
...

Issue and fix
------------------
/classes/request/parser.php:263

Because you're using dirname() and then checking for === '/' this fails.
dirname() will ofcourse return a \ for its path instead of /
For a quick fix i have simply done a str_replace() looking for / to be replaced by /
...


The function now looks like this.

protected function sanitizeUrl( $url )
{
    if ( ( $pos = strpos( $url, '.phar' ) ) !== false )
    {
        $this->basePath = substr( $url, 0, $pos + 5 );
    }
    else
    {
        $this->basePath = dirname( arbitHttpTools::serverVariable( 'PHP_SELF' ) );
    }

    // Windows path fix
    $this->basePath = str_replace('\\', '/', $this->basePath);
    
    // Dirname returns a single / for a root path, but we NEVER want a
    // trailing slash
    if ( $this->basePath === '/' )
    {
        $this->basePath = '';
    }

    // Use only the stuff following teh base path for routing
    return str_replace( $this->basePath, '', $url );
}
  • dr4g at Thursday 28 January 2010 02:17:29 UTC

    Typo.. For a quick fix i have simply done a str_replace() looking for / to be replaced by /

    Should be.. For a quick fix i have simply done a str_replace() looking for to be replaced by /

  • Jordi Boggiano at Thursday 28 January 2010 08:30:46 UTC

    It was actually already fixed in revision #1544, I'm sorry I didn't report a bug for it since it was a really tiny fix.

    Thanks for reporting but please try and run it from trunk to avoid that kind of duplicate work in the future (at least until we're out of alpha), a lot has been fixed since 0.2 already, and trunk is normally quite stable.

  • Jordi Boggiano at Thursday 28 January 2010 08:33:06 UTC

    God I hate ReST markup :)

    Correct link is http://tracker.arbitracker.org/arbit/browse_source/diff/src/?to=1544&from=1543 - but I don't know if it's gonna be mis-encoded again even without the proper link syntax.