diff --git a/ChangeLog b/ChangeLog index abc660739cf..cdcef2d4e4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,7 +15,10 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * PHP 5.5 is no more supported. Minimum PHP is now 5.6+. - +* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests + with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing + the HTML into content (in such a case, sanitize data later) + ***** ChangeLog for 11.0.1 compared to 11.0.0 ***** diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 2e39105eb21..da23d3cc33b 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -157,7 +157,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) foreach ($listfield as $f => $value) { if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory - if ((! isset($_POST[$value]) || $_POST[$value]=='')) + if ((! GETPOSTISSET($value)) || GETPOST($value) == '') { $ok=0; $fieldnamekey=$listfield[$f]; @@ -170,13 +170,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) } } // Other checks - if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system','systemauto'))) { + if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system','systemauto'))) { $ok=0; setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); } - if (isset($_POST["pcg_version"])) + if (GETPOSTISSET("pcg_version")) { - if ($_POST["pcg_version"]=='0') + if (GETPOST("pcg_version") == '0') { $ok=0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index dbe20bba99d..2924feb58eb 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -153,7 +153,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'country' || $value == 'country_id') continue; - if (!isset($_POST[$value]) || $_POST[$value] == '') + if (! GETPOSTISSET($value) || GETPOST($value) == '') { $ok = 0; $fieldnamekey = $listfield[$f]; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 62313faa2f2..e47fba72756 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -165,9 +165,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal'; } // Other checks - if (isset($_POST["code"])) + if (GETPOSTISSET("code")) { - if ($_POST["code"] == '0') + if (GETPOST("code") == '0') { $ok = 0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 57c50e1b6b3..02941cb9967 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -214,7 +214,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') // Type print '
'.print_r($setupconst, true).''; - $result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); + + $constname = dol_escape_htmltag($setupconst['varname']); + $constvalue = dol_escape_htmltag($setupconst['value']); + $consttype = dol_escape_htmltag($setupconst['type']); + $constnote = dol_escape_htmltag($setupconst['note']); + + $result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity); if (!$result > 0) $error++; } diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index e85853541de..07891630c1a 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -70,8 +70,8 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) elseif ($action == 'updateform') { - $res1=dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", $_POST["MAIN_APPLICATION_TITLE"], 'chaine', 0, '', $conf->entity); - $res2=dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"], 'chaine', 0, '', $conf->entity); + $res1=dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + $res2=dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity); if ($res1 && $res2) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index b725a2e50ae..4a70104158b 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors")); +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button + if (!$user->admin) accessforbidden(); @@ -46,14 +48,13 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'update' && empty($_POST["cancel"])) +if ($action == 'update' && !$cancel) { - dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", $_POST["MAIN_DISABLE_ALL_SMS"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", GETPOST("MAIN_DISABLE_ALL_SMS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SMS_SENDMODE", $_POST["MAIN_SMS_SENDMODE"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SMS_SENDMODE", GETPOST("MAIN_SMS_SENDMODE", 'alphahtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", $_POST["MAIN_MAIL_SMS_FROM"], 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", GETPOST("MAIN_MAIL_SMS_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -68,15 +69,15 @@ if ($action == 'send' && !$_POST['cancel']) $error = 0; $smsfrom = ''; - if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms"); - if (empty($smsfrom)) $smsfrom = GETPOST("fromname"); - $sendto = GETPOST("sendto"); - $body = GETPOST('message'); - $deliveryreceipt = GETPOST("deliveryreceipt"); - $deferred = GETPOST('deferred'); - $priority = GETPOST('priority'); - $class = GETPOST('class'); - $errors_to = GETPOST("errorstosms"); + if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms", 'alphanohtml'); + if (empty($smsfrom)) $smsfrom = GETPOST("fromname", 'alphanohtml'); + $sendto = GETPOST("sendto", 'alphanohtml'); + $body = GETPOST('message', 'alphanohtml'); + $deliveryreceipt = GETPOST("deliveryreceipt", 'alphanohtml'); + $deferred = GETPOST('deferred', 'alphanohtml'); + $priority = GETPOST('priority', 'alphanohtml'); + $class = GETPOST('class', 'alphanohtml'); + $errors_to = GETPOST("errorstosms", 'alphanohtml'); // Create form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index 5b5bf692e22..d33728286e9 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -50,18 +50,20 @@ $action = GETPOST('action', 'aZ09'); // Action mise a jour ou ajout d'une constante if ($action == 'update' || $action == 'add') { - $constname=GETPOST("constname"); - $constvalue=GETPOST("constvalue"); + $constnamearray = GETPOST("constname", 'array'); + $constvaluearray = GETPOST("constvalue", 'array'); + $consttypearray = GETPOST("consttype", 'array'); + $constnotearray = GETPOST("constnote", 'array'); // Action mise a jour ou ajout d'une constante if ($action == 'update' || $action == 'add') { - foreach($_POST['constname'] as $key => $val) + foreach($constnamearray as $key => $val) { - $constname=$_POST["constname"][$key]; - $constvalue=$_POST["constvalue"][$key]; - $consttype=$_POST["consttype"][$key]; - $constnote=$_POST["constnote"][$key]; + $constname = dol_escape_htmltag($constnamearray[$key]); + $constvalue = dol_escape_htmltag($constvaluearray[$key]); + $consttype = dol_escape_htmltag($consttypearray[$key]); + $constnote = dol_escape_htmltag($constnotearray[$key]); $res=dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 9a17916cb49..977b99d0c99 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -171,7 +171,7 @@ if ($action == 'setmod') if ($action == 'addcat') { $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, $_POST["cat"]); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 1b6b6eb9921..db9b3e257f6 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -165,7 +165,7 @@ elseif ($action == 'setmod') elseif ($action == 'addcat') { $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, $_POST["cat"]); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } elseif ($action == 'set_SUPPLIER_ORDER_OTHER') diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index d639b8d2a9b..689b65cc954 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -132,7 +132,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) $ok=1; foreach ($listfield as $f => $value) { - if ($value == 'ref' && (! isset($_POST[$value]) || $_POST[$value]=='')) + if ($value == 'ref' && (! GETPOSTISSET($value) || GETPOST($value) == '')) { $ok=0; $fieldnamekey=$listfield[$f]; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 9f5f8597663..542dbc8e23d 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -609,37 +609,15 @@ if ($rowid > 0) print $object->showOptionals($extrafields, 'edit', $parameters); } - print ''; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - // Extra field - if (empty($reshook)) - { - print '
| '.$label.' | '; - print $extrafields->showInputField($key, $value); - print " |