Skip to content

Commit

Permalink
feature 414 (yes, a 6 years old request): ability to define the list of
Browse files Browse the repository at this point in the history
permitted characters in file/directory names for synchronization.


git-svn-id: http://piwigo.org/svn/trunk@13527 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Mar 10, 2012
1 parent b1c58f5 commit e0f6d5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions admin/site_update.php
Expand Up @@ -208,7 +208,7 @@
foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir)
{
$dir = basename($fulldir);
if (preg_match('/^[a-zA-Z0-9-_.]+$/', $dir))
if (preg_match($conf['sync_chars_regex'], $dir))
{
$insert = array(
'id' => $next_id++,
Expand Down Expand Up @@ -374,7 +374,7 @@
continue;
}
$filename = basename($path);
if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
if (!preg_match($conf['sync_chars_regex'], $filename))
{
array_push(
$errors,
Expand Down
6 changes: 5 additions & 1 deletion i.php
Expand Up @@ -194,8 +194,12 @@ function parse_request()
}

$req = ltrim($req, '/');
!preg_match('#[^a-zA-Z0-9/_.-]#', $req) or ierror('Invalid chars in request', 400);

foreach (preg_split('#/+#', $req) as $token)
{
preg_match($conf['sync_chars_regex'], $token) or ierror('Invalid chars in request', 400);
}

$page['derivative_path'] = PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$req;

$pos = strrpos($req, '.');
Expand Down
3 changes: 3 additions & 0 deletions include/config_default.inc.php
Expand Up @@ -746,6 +746,9 @@
// enable the synchronization method for adding photos
$conf['enable_synchronization'] = true;

// permitted characters for files/directoris during synchronization
$conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_.]+$/';

// PEM url
$conf['alternative_pem_url'] = '';

Expand Down

0 comments on commit e0f6d5d

Please sign in to comment.