I had very bad time debugging a server 406 error
and finally I found out that the reason was mysql_escape_string
.
It look that this function doesn't handle well big string ( > 7685 char ) and anyway it is not quoting properly html content.
In the function definition it is written:
- @deprecated since 5.3.0, use mysql_real_escape_string() instead
I cannot find any info on php.net related to the use of mysql_real_escape_string()
as substitute of mysql_escape_string()
Here the portion of the code that is not working fine:
$textQuoted = mysql_escape_string($text);
$sql .= " lower('" . $textQuoted . "') LIKE CONCAT('%', lower(keyword), '%')")
UPDATE
All this is happening on Magento, that relay on Zend Framework.
Magento/Varien/Zend is using PDO so I have tried to use the quote()
function provided by Varien/Zend Framework but the issue persist.
Finally the issue is related to MySql and the setting max_allowed_packet
that is too low: so big strings was creating a big SQL query that was crashing the page.
note
I don't know why someone thinks this question is somehow related to SQL injection ... anyway the world is nice because everybody is different.
Thanks for the effort to the nice stackoverflow comunity