mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-22 22:02:15 +01:00
Updated regex pull to use constant, set default of file list result to empty array
This commit is contained in:
parent
fd11904f89
commit
4221ef34ba
4 changed files with 11 additions and 7 deletions
|
@ -12,6 +12,8 @@ require_once('./class.archive.php');
|
||||||
|
|
||||||
class Filemanager extends Common {
|
class Filemanager extends Common {
|
||||||
|
|
||||||
|
const PATH_REGEX = '/[^\w\-\._@]/';
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// PROPERTIES
|
// PROPERTIES
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -602,7 +602,7 @@
|
||||||
|
|
||||||
let data = await _this.get_indexes( path );
|
let data = await _this.get_indexes( path );
|
||||||
let response = codiad.jsend.parse( data );
|
let response = codiad.jsend.parse( data );
|
||||||
let result = null;
|
let result = [];
|
||||||
|
|
||||||
if( response != 'error' ) {
|
if( response != 'error' ) {
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ require_once( __DIR__ . "/../settings/class.settings.php" );
|
||||||
|
|
||||||
class Install {
|
class Install {
|
||||||
|
|
||||||
|
const PATH_REGEX = '/[^\w\-\._@]/';
|
||||||
|
|
||||||
public $active = "";
|
public $active = "";
|
||||||
public $config = "";
|
public $config = "";
|
||||||
public $db_types = array();
|
public $db_types = array();
|
||||||
|
@ -84,7 +86,7 @@ class Install {
|
||||||
|
|
||||||
function clean_username( $username ) {
|
function clean_username( $username ) {
|
||||||
|
|
||||||
return strtolower( preg_replace( '/[^\w\-\._@]/', '-', $username ) );
|
return strtolower( preg_replace( self::PATH_REGEX, '-', $username ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_config() {
|
function create_config() {
|
||||||
|
@ -157,7 +159,7 @@ define("WSURL", BASE_URL . "/workspace");
|
||||||
|
|
||||||
if ( ! $this->is_abs_path( $project_path ) ) {
|
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;
|
$project_path = $this->username . "/" . $project_path;
|
||||||
|
|
||||||
if( ! is_dir( $this->workspace . "/" . $project_path ) ) {
|
if( ! is_dir( $this->workspace . "/" . $project_path ) ) {
|
||||||
|
|
|
@ -414,7 +414,7 @@ class Project extends Common {
|
||||||
}
|
}
|
||||||
if ( $path != '' ) {
|
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 ) ) {
|
if( ! $this->isAbsPath( $path ) ) {
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ class Project extends Common {
|
||||||
|
|
||||||
if( ! is_dir( WORKSPACE . '/' . $path ) ) {
|
if( ! is_dir( WORKSPACE . '/' . $path ) ) {
|
||||||
|
|
||||||
mkdir( WORKSPACE . '/' . $path );
|
mkdir( WORKSPACE . '/' . $path, 0755, true );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -576,13 +576,13 @@ class Project extends Common {
|
||||||
public function SanitizePath() {
|
public function SanitizePath() {
|
||||||
|
|
||||||
$sanitized = str_replace( " ", "_", $this->path );
|
$sanitized = str_replace( " ", "_", $this->path );
|
||||||
return preg_replace( '/[^\w-]/', '', strtolower( $sanitized ) );
|
return preg_replace( Filemanager::PATH_REGEX, '', strtolower( $sanitized ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sanitize_path( $path ) {
|
public function sanitize_path( $path ) {
|
||||||
|
|
||||||
$sanitized = str_replace( " ", "_", $path );
|
$sanitized = str_replace( " ", "_", $path );
|
||||||
return preg_replace( '/[^\w-]/', '', strtolower( $sanitized ) );
|
return preg_replace( Filemanager::PATH_REGEX, '', strtolower( $sanitized ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in a new issue