Skip to content

Commit

Permalink
FIX sanitize setup params
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Apr 18, 2018
1 parent 5d121b2 commit 6b3e5e2
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 80 deletions.
34 changes: 6 additions & 28 deletions htdocs/admin/agenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$search_event = '';
$action = '';
}

if (GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') ||GETPOST('button_search','alpha')) // To avoid the save when we click on search
{
$action = '';
}

if ($action == "save" && empty($cancel))
Expand Down Expand Up @@ -106,34 +112,6 @@
}
}

if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
$value=(GETPOST($code) ? GETPOST($code) : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}

if (preg_match('/del_(.*)/',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}


/**
Expand Down
6 changes: 3 additions & 3 deletions htdocs/admin/agenda_other.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@

include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';

if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
$value=(GETPOST($code) ? GETPOST($code) : 1);
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
Expand All @@ -67,7 +67,7 @@
}
}

if (preg_match('/del_(.*)/',$action,$reg))
if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
6 changes: 3 additions & 3 deletions htdocs/admin/agenda_reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@

include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';

if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
$value=(GETPOST($code) ? GETPOST($code) : 1);
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
Expand All @@ -62,7 +62,7 @@
}
}

if (preg_match('/del_(.*)/',$action,$reg))
if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/ecm.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/*
* Action
*/
if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
Expand All @@ -47,7 +47,7 @@
}
}

if (preg_match('/del_(.*)/',$action,$reg))
if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
7 changes: 4 additions & 3 deletions htdocs/admin/multicurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@
*/


if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0)
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
Expand All @@ -62,7 +63,7 @@
}
}

if (preg_match('/del_(.*)/',$action,$reg))
if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, 0) > 0)
Expand Down
31 changes: 1 addition & 30 deletions htdocs/admin/security_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,7 @@
dol_add_file_process($upload_dir, 0, 0, 'userfile');
}

if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}

else if (preg_match('/del_(.*)/',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}

else if ($action == 'updateform')
if ($action == 'updateform')
{
$antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND','none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe
$antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM','none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib"
Expand Down
6 changes: 3 additions & 3 deletions htdocs/admin/security_other.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
* Actions
*/

if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
$value=(GETPOST($code) ? GETPOST($code) : 1);
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
Expand All @@ -58,7 +58,7 @@
}
}

else if (preg_match('/del_(.*)/',$action,$reg))
else if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
}
$res = true;
}
elseif (preg_match('/set_(.*)/',$action,$reg))
elseif (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
Expand All @@ -100,7 +100,7 @@
}
}

elseif (preg_match('/del_(.*)/',$action,$reg))
elseif (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/usergroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
}
$res = true;
}
elseif (preg_match('/set_(.*)/',$action,$reg))
elseif (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
Expand All @@ -97,7 +97,7 @@
}
}

elseif (preg_match('/del_(.*)/',$action,$reg))
elseif (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/categories/admin/categorie.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Actions
*/

if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
Expand All @@ -52,7 +52,7 @@
}
}

if (preg_match('/del_(.*)/',$action,$reg))
if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/margin/admin/margin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/*
* Action
*/
if (preg_match('/set_(.*)/',$action,$reg))
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0)
Expand All @@ -56,7 +56,7 @@
}
}

if (preg_match('/del_(.*)/',$action,$reg))
if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
Expand Down

0 comments on commit 6b3e5e2

Please sign in to comment.