This repository was archived by the owner on Nov 25, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -90,12 +90,12 @@ public static function natkrsort(&$array)
90
90
*/
91
91
public static function securePath ($ path )
92
92
{
93
- if ($ path == null ) $ path = "" ;
93
+ if ($ path == null ) return "" ;
94
94
//
95
95
// REMOVE ALL "../" TENTATIVES
96
96
//
97
97
$ path = str_replace (chr (0 ), "" , $ path );
98
- $ dirs = explode ( ' / ' , $ path );
98
+ $ dirs = self :: safeExplode ( $ path );
99
99
for ($ i = 0 ; $ i < count ($ dirs ); $ i ++) {
100
100
if ($ dirs [$ i ] == '. ' or $ dirs [$ i ] == '.. ' ) {
101
101
$ dirs [$ i ] = '' ;
@@ -113,13 +113,15 @@ public static function securePath($path)
113
113
return $ path ;
114
114
}
115
115
116
- public static function safeDirname ($ path )
117
- {
116
+ public static function safeExplode ($ path ) {
117
+ return (DIRECTORY_SEPARATOR === "\\" ? preg_split ('/( \\\| \\/)/ ' , $ path ) : explode ('/ ' , $ path ));
118
+ }
119
+
120
+ public static function safeDirname ($ path ) {
118
121
return (DIRECTORY_SEPARATOR === "\\" ? str_replace ("\\" , "/ " , dirname ($ path )): dirname ($ path ));
119
122
}
120
123
121
- public static function safeBasename ($ path )
122
- {
124
+ public static function safeBasename ($ path ) {
123
125
return (DIRECTORY_SEPARATOR === "\\" ? str_replace ("\\" , "/ " , basename ($ path )): basename ($ path ));
124
126
}
125
127
You can’t perform that action at this time.
0 commit comments