2
0
forked from Wavyzz/dolibarr

Clean code

This commit is contained in:
Laurent Destailleur
2023-05-12 19:21:47 +02:00
parent 3322a5eeb8
commit 4c1c6319b3

View File

@@ -952,7 +952,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
} }
} }
break; break;
case 'aZ09arobase': // great to sanitize objecttype parameter case 'aZ09arobase': // great to sanitize $objecttype parameter
if (!is_array($out)) { if (!is_array($out)) {
$out = trim($out); $out = trim($out);
if (preg_match('/[^a-z0-9_\-\.@]+/i', $out)) { if (preg_match('/[^a-z0-9_\-\.@]+/i', $out)) {
@@ -960,7 +960,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
} }
} }
break; break;
case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh case 'aZ09comma': // great to sanitize $sortfield or $sortorder params that can be 't.abc,t.def_gh'
if (!is_array($out)) { if (!is_array($out)) {
$out = trim($out); $out = trim($out);
if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) {
@@ -968,9 +968,6 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
} }
} }
break; break;
case 'nohtml': // No html
$out = dol_string_nohtmltag($out, 0);
break;
case 'alpha': // No html and no ../ and " case 'alpha': // No html and no ../ and "
case 'alphanohtml': // Recommended for most scalar parameters and search parameters case 'alphanohtml': // Recommended for most scalar parameters and search parameters
if (!is_array($out)) { if (!is_array($out)) {
@@ -1002,6 +999,9 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
} while ($oldstringtoclean != $out); } while ($oldstringtoclean != $out);
} }
break; break;
case 'nohtml': // No html
$out = dol_string_nohtmltag($out, 0);
break;
case 'restricthtml': // Recommended for most html textarea case 'restricthtml': // Recommended for most html textarea
case 'restricthtmlnolink': case 'restricthtmlnolink':
case 'restricthtmlallowunvalid': case 'restricthtmlallowunvalid':
@@ -7391,6 +7391,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
* @param string $pagecodefrom Pagecode stringtoencode is encoded * @param string $pagecodefrom Pagecode stringtoencode is encoded
* @param int $removelasteolbr 1=Remove last br or lasts \n (default), 0=Do nothing * @param int $removelasteolbr 1=Remove last br or lasts \n (default), 0=Do nothing
* @return string String encoded * @return string String encoded
* @see dolGetFirstLineOfText()
*/ */
function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8', $removelasteolbr = 1) function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8', $removelasteolbr = 1)
{ {