Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/SimpleSAML/Utils/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ public function resolvePath(string $path, ?string $base = null): string
// check for absolute path
if (substr($path, 0, 1) === '/') {
// absolute path. */
$ret = '/';
if (substr($path, 0, 2) === '//') {
// UNC absolute path
$ret = '//';
} else {
$ret = '/';
}
} elseif ($this->pathContainsDriveLetter($path)) {
$ret = '';
} else {
Expand Down
17 changes: 17 additions & 0 deletions tests/src/SimpleSAML/Utils/SystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,21 @@ protected function clearInstance(Configuration $service, string $className): voi
$reflectedInstance->setValue($service, []);
$reflectedInstance->setAccessible(false);
}


/**
*/
public function testUNCpaths(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right. If the separator is \\ then the UNC-path should also use backslashes?

{
if (DIRECTORY_SEPARATOR == '\\') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick, but please use strict comparison (===)


$base = null;
$path = "\\some-pc\some-share\some.key";

$res = $this->sysUtils->resolvePath($path, $base);
$expected = "//some-pc/some-share/some.key";

$this->assertEquals($expected, $res);
}
}
}
Loading