Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
31442318
Unverified
Commit
31442318
authored
7 years ago
by
Thijs Kinkhorst
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #564 from LukeCarrier/windows-paths
Improve handling of paths containing Windows-style drive letters
parents
68be96da
5f483bb5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/SimpleSAML/Configuration.php
+2
-13
2 additions, 13 deletions
lib/SimpleSAML/Configuration.php
lib/SimpleSAML/Utils/System.php
+22
-1
22 additions, 1 deletion
lib/SimpleSAML/Utils/System.php
tests/lib/SimpleSAML/ConfigurationTest.php
+3
-0
3 additions, 0 deletions
tests/lib/SimpleSAML/ConfigurationTest.php
with
27 additions
and
14 deletions
lib/SimpleSAML/Configuration.php
+
2
−
13
View file @
31442318
<?php
use
SimpleSAML\Utils\System
;
/**
* Configuration of SimpleSAMLphp
...
...
@@ -568,19 +569,7 @@ class SimpleSAML_Configuration implements \SimpleSAML\Utils\ClearableState
assert
(
is_string
(
$path
));
/* Prepend path with basedir if it doesn't start with a slash or a Windows drive letter (e.g. "C:\"). We assume
* getBaseDir ends with a slash.
*/
if
(
$path
[
0
]
!==
'/'
&&
!
(
preg_match
(
'@^[a-z]:[\\\\/]@i'
,
$path
,
$matches
)
&&
is_dir
(
$matches
[
0
]))
)
{
$path
=
$this
->
getBaseDir
()
.
$path
;
}
// remove trailing slashes
$path
=
rtrim
(
$path
,
'/'
);
return
$path
;
return
System
::
resolvePath
(
$path
,
$this
->
getBaseDir
());
}
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Utils/System.php
+
22
−
1
View file @
31442318
...
...
@@ -122,13 +122,20 @@ class System
$base
=
$config
->
getBaseDir
();
}
// normalise directory separator
$base
=
str_replace
(
'\\'
,
'/'
,
$base
);
$path
=
str_replace
(
'\\'
,
'/'
,
$path
);
// remove trailing slashes
$base
=
rtrim
(
$base
,
'/'
);
$path
=
rtrim
(
$path
,
'/'
);
// check for absolute path
if
(
substr
(
$path
,
0
,
1
)
===
'/'
)
{
// absolute path. */
$ret
=
'/'
;
}
elseif
(
static
::
pathContainsDriveLetter
(
$path
))
{
$ret
=
''
;
}
else
{
// path relative to base
$ret
=
$base
;
...
...
@@ -141,7 +148,7 @@ class System
}
elseif
(
$d
===
'..'
)
{
$ret
=
dirname
(
$ret
);
}
else
{
if
(
substr
(
$ret
,
-
1
)
!==
'/'
)
{
if
(
$ret
&&
substr
(
$ret
,
-
1
)
!==
'/'
)
{
$ret
.
=
'/'
;
}
$ret
.
=
$d
;
...
...
@@ -215,4 +222,18 @@ class System
opcache_invalidate
(
$filename
);
}
}
/**
* Check if the supplied path contains a Windows-style drive letter.
*
* @param string $path
*
* @return bool
*/
private
static
function
pathContainsDriveLetter
(
$path
)
{
$letterAsciiValue
=
ord
(
strtoupper
(
substr
(
$path
,
0
,
1
)));
return
substr
(
$path
,
1
,
1
)
===
':'
&&
$letterAsciiValue
>=
65
&&
$letterAsciiValue
<=
90
;
}
}
This diff is collapsed.
Click to expand it.
tests/lib/SimpleSAML/ConfigurationTest.php
+
3
−
0
View file @
31442318
...
...
@@ -220,6 +220,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
$this
->
assertEquals
(
$c
->
resolvePath
(
'slash/'
),
'/basedir/slash'
);
$this
->
assertEquals
(
$c
->
resolvePath
(
'slash//'
),
'/basedir/slash'
);
$this
->
assertEquals
(
$c
->
resolvePath
(
'C:\\otherdir'
),
'C:/otherdir'
);
$this
->
assertEquals
(
$c
->
resolvePath
(
'C:/otherdir'
),
'C:/otherdir'
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment