Skip to content

Commit

Permalink
Fix #579. Fix Nested sub path parsing in buildWithBaseURLPath. Fix te…
Browse files Browse the repository at this point in the history
…sts.
  • Loading branch information
pitbulk committed May 30, 2024
1 parent 91c1a3b commit 964e420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Saml2/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,10 @@ protected static function buildWithBaseURLPath($info)
if (!empty($baseURLPath)) {
$result = $baseURLPath;
if (!empty($info)) {
$path = explode('/', $info);
$extractedInfo = array_pop($path);
// Remove base path from the path info.
$extractedInfo = str_replace($baseURLPath, '', $info);
// Remove starting and ending slash.
$extractedInfo = trim($extractedInfo, '/');
if (!empty($extractedInfo)) {
$result .= $extractedInfo;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/src/OneLogin/Saml2/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ public function testSetBaseURL()
$this->assertEquals($expectedUrl, Utils::getSelfURL());

Utils::setBaseURL("http://anothersp.example.com:81/example2/");
$expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php';
$expectedRoutedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php';
$expectedUrl2 = 'http://anothersp.example.com:81/example2/route.php?x=test';
$expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/example1/route.php';
$expectedRoutedUrlNQ2 = 'http://anothersp.example.com:81/example2/example1/route.php';
$expectedUrl2 = 'http://anothersp.example.com:81/example2/example1/route.php?x=test';

$this->assertEquals('http', Utils::getSelfProtocol());
$this->assertEquals('anothersp.example.com', Utils::getSelfHost());
Expand All @@ -517,7 +517,7 @@ public function testSetBaseURL()
$this->assertEquals($expectedUrl2, Utils::getSelfURL());

$_SERVER['PATH_INFO'] = '/test';
$expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php/test';
$expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/example1/route.php/test';

$this->assertEquals($expectedUrlNQ2, Utils::getSelfURLNoQuery());
$this->assertEquals($expectedRoutedUrlNQ2, Utils::getSelfRoutedURLNoQuery());
Expand Down

0 comments on commit 964e420

Please sign in to comment.