Skip to content

Commit

Permalink
Merge branch 'JoeBengalen-fix-basepath-space' into 3.x
Browse files Browse the repository at this point in the history
Closes #1946
  • Loading branch information
akrabat committed Mar 18, 2017
2 parents 7aabd47 + df1591c commit c2d7ae4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Slim/Http/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public static function createFromEnvironment(Environment $env)
// parse_url() requires a full URL. As we don't extract the domain name or scheme,
// we use a stand-in.
$requestUri = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_PATH);
$requestUri = rawurldecode($requestUri);

$basePath = '';
$virtualPath = $requestUri;
Expand Down
14 changes: 14 additions & 0 deletions tests/Http/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,20 @@ public function testCreateEnvironmentWithBasePath()
$this->assertEquals('http://localhost/foo/bar', (string) $uri);
}

public function testCreateEnvironmentWithBasePathContainingSpace()
{
$environment = Environment::mock([
'SCRIPT_NAME' => "/f'oo bar/index.php",
'REQUEST_URI' => "/f'oo%20bar/baz",
]);
$uri = Uri::createFromEnvironment($environment);

$this->assertEquals("/f%27oo%20bar", $uri->getBasePath());
$this->assertEquals('baz', $uri->getPath());

$this->assertEquals('http://localhost/f%27oo%20bar/baz', (string) $uri);
}

public function testGetBaseUrl()
{
$environment = Environment::mock([
Expand Down

0 comments on commit c2d7ae4

Please sign in to comment.