Domanda

Sto diventando sfocatura per questo :P

function escape($string)
{
    $string = stripslashes($string);

    if (function_exists('mysql_real_escape_string')) {
       return mysql_real_escape_string($string, $this->connection);
    } else {
        return mysql_escape_string($string);
    }
}

$content = '""""""test\'te%%%%st`test_huhu\'_';

echo '<br>output 1 = '.stripslashes($content);
echo '<br>output 2 = '.$db->escape($content);

L'uscita

output 1 =  """"""test'te%%%%st`test_huhu'_
output 2 =  \"\"\"\"\"\"test\'te%%%%st`test_huhu\'_ 

Come fare output 2 sarà lo stesso come output 1 e perché il output 2 per essere come quello?

È stato utile?

Soluzione

mysql_real_escape_string sfugge a tutte " e ' ecco perché è possibile ottenere tutti quei tagli.Se si rimuove le barre prima di mettere i dati in un database che si sta per aprire attacchi che è molto male per la sicurezza non credi?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top