@ 2021-06-21T17:32:15Z <?php
//--------------------------------------------------
// Just while the function is re-named
if (!function_exists('is_trusted')) {
function is_trusted($value) {
return is_literal($value);
}
}
//--------------------------------------------------
$limit = trim(' 100 '); // Not trusted
$_GET['ids'] = [trim(' 1 '), 2, 3];
var_dump($_GET['ids'][0], is_trusted($_GET['ids'][0]));
$ids_untrusted = ( $_GET['ids'] ?? [] );
$ids_trusted = array_map( 'intval', $ids_untrusted );
//--------------------------------------------------
$sql = 'SELECT * FROM foo WHERE id IN (' . implode( ',', $ids_untrusted ) . ')'; // Whoops
var_dump($sql, is_trusted($sql));
//--------------------------------------------------
$sql = 'SELECT * FROM foo WHERE id IN (' . implode( ',', $ids_trusted ) . ')';
var_dump($sql, is_trusted($sql));
//--------------------------------------------------
$sql = sprintf( 'SELECT * FROM foo WHERE id IN (%s)', implode( ',', $ids_trusted ) );
var_dump($sql, is_trusted($sql));
//--------------------------------------------------
$sql = sprintf( 'SELECT * FROM foo LIMIT %d', (int)$limit );
var_dump($sql, is_trusted($sql));
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.011 0.011 18.55 8.3.5 0.011 0.004 17.98 8.3.4 0.015 0.007 18.75 8.3.3 0.008 0.008 19.00 8.3.2 0.000 0.008 24.18 8.3.1 0.007 0.000 24.66 8.3.0 0.004 0.004 26.16 8.2.18 0.014 0.007 25.92 8.2.17 0.012 0.003 22.96 8.2.16 0.008 0.006 22.96 8.2.15 0.009 0.000 25.66 8.2.14 0.000 0.008 24.66 8.2.13 0.000 0.007 26.16 8.2.12 0.000 0.008 19.48 8.2.11 0.000 0.009 20.39 8.2.10 0.000 0.010 20.52 8.1.28 0.013 0.007 25.92 8.1.27 0.004 0.004 23.99 8.1.26 0.005 0.003 26.35 8.1.25 0.004 0.004 28.09 8.1.24 0.000 0.009 20.90 8.1.23 0.010 0.000 19.00
preferences:dark mode live preview
50.85 ms | 400 KiB | 5 Q