Skip to content

Commit

Permalink
Allow microsoft abs path on microsoft. Fixes #293
Browse files Browse the repository at this point in the history
  • Loading branch information
rosell-dk committed Jun 28, 2019
1 parent b3fd4c2 commit dc5d5bb
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions lib/classes/SanityCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,45 @@ public static function pathBeginsWith($input, $beginsWith, $errorMsg = 'Path is
return $input;
}

public static function absPathMicrosoftStyle($input, $errorMsg = 'Not an fully qualified Windows path')
{
// On microsoft we allow [drive letter]:\
if (!preg_match("#^[A-Z]:\\\\|/#", $input)) {
throw new SanityException($errorMsg . ':' . $input);
}
return $input;
}

public static function absPath($input, $errorMsg = 'Not an absolute path')
{
if ((strpos($input, '/') !== 0)) {
throw new SanityException($errorMsg . $input);
// On microsoft, allow

$onMicrosoft = false;
if (isset($_SERVER['SERVER_SOFTWARE'])) {
if (strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'microsoft') !== false) {
$onMicrosoft = true;
}
}
switch (PHP_OS) {
case "WINNT":
case "WIN32":
case "INTERIX":
case "UWIN":
case "UWIN-W7":
$onMicrosoft = true;
break;
}

if (!$onMicrosoft) {
throw new SanityException($errorMsg . ':' . $input);
}
self::absPathMicrosoftStyle($input);

}
return self::path($input);
}

private static function findClosestExistingFolderSymLinksExpanded($input) {
// Get closest existing folder with symlinks expanded.
// this is a bit complicated, as the input path may not yet exist.
Expand Down

0 comments on commit dc5d5bb

Please sign in to comment.