Updated regex pull to use constant, set default of file list result to empty array

This commit is contained in:
xevidos 2019-12-11 11:23:33 -05:00
parent fd11904f89
commit 4221ef34ba
4 changed files with 11 additions and 7 deletions

View File

@ -12,6 +12,8 @@ require_once('./class.archive.php');
class Filemanager extends Common {
const PATH_REGEX = '/[^\w\-\._@]/';
//////////////////////////////////////////////////////////////////
// PROPERTIES
//////////////////////////////////////////////////////////////////

View File

@ -602,7 +602,7 @@
let data = await _this.get_indexes( path );
let response = codiad.jsend.parse( data );
let result = null;
let result = [];
if( response != 'error' ) {

View File

@ -5,6 +5,8 @@ require_once( __DIR__ . "/../settings/class.settings.php" );
class Install {
const PATH_REGEX = '/[^\w\-\._@]/';
public $active = "";
public $config = "";
public $db_types = array();
@ -84,7 +86,7 @@ class Install {
function clean_username( $username ) {
return strtolower( preg_replace( '/[^\w\-\._@]/', '-', $username ) );
return strtolower( preg_replace( self::PATH_REGEX, '-', $username ) );
}
function create_config() {
@ -157,7 +159,7 @@ define("WSURL", BASE_URL . "/workspace");
if ( ! $this->is_abs_path( $project_path ) ) {
$project_path = preg_replace( '/[^\w\-._@]/', '-', $project_path );
$project_path = preg_replace( self::PATH_REGEX, '-', $project_path );
$project_path = $this->username . "/" . $project_path;
if( ! is_dir( $this->workspace . "/" . $project_path ) ) {

View File

@ -414,7 +414,7 @@ class Project extends Common {
}
if ( $path != '' ) {
$user_path = WORKSPACE . '/' . preg_replace( '/[^\w-]/', '', strtolower( $_SESSION["user"] ) );
$user_path = WORKSPACE . '/' . preg_replace( Filemanager::PATH_REGEX, '', strtolower( $_SESSION["user"] ) );
if( ! $this->isAbsPath( $path ) ) {
@ -433,7 +433,7 @@ class Project extends Common {
if( ! is_dir( WORKSPACE . '/' . $path ) ) {
mkdir( WORKSPACE . '/' . $path );
mkdir( WORKSPACE . '/' . $path, 0755, true );
}
} else {
@ -576,13 +576,13 @@ class Project extends Common {
public function SanitizePath() {
$sanitized = str_replace( " ", "_", $this->path );
return preg_replace( '/[^\w-]/', '', strtolower( $sanitized ) );
return preg_replace( Filemanager::PATH_REGEX, '', strtolower( $sanitized ) );
}
public function sanitize_path( $path ) {
$sanitized = str_replace( " ", "_", $path );
return preg_replace( '/[^\w-]/', '', strtolower( $sanitized ) );
return preg_replace( Filemanager::PATH_REGEX, '', strtolower( $sanitized ) );
}
//////////////////////////////////////////////////////////////////