我刚刚读到在较新版本的Cake中,Sanitize类将被删除。我正在使用CakePHP 2.3,我认为它已被弃用。通常我会为我正在尝试编写的查询使用预准备语句,但我不相信在使用paginate组件时这是可能的。最终我将对结果进行分页,但这是我到目前为止查询的选项:
$options = array(
'joins' => array(
array(
'table' => '(SELECT search_terms.name, product_search_terms.product_id AS product_id_1
FROM product_search_terms
JOIN search_terms ON search_terms.id = product_search_terms.search_term_id
)',
'alias' => 'SearchTerm',
'conditions' => array(
'SearchTerm.product_id_1 = Product.id',
'LOWER(SearchTerm.name) REGEXP "[[:<:]]' . $word . '[[:>:]]"', //Here's the line that is vulnerable
)
)
),
'fields' => array('Product.id', 'SearchTerm.name'),
);
'LOWER(SearchTerm.name)REGEXP'[[:&lt;:]]'。$ word。'[[:&gt;:]]“',肯定容易受到SQL注入攻击。如果不使用Sanitize或准备好的声明,是否可以预防这种情况?