system/library 下的 Cart.php 有一个正则表达式模式定义,它不允许我使用阿拉伯语作为名称值。这有效:
$data = array(
'id' => "221212",
'qty' => 1,
'price' => 21.2,
'name' => 'dasdasdas'
);
但这失败了,因为名称中有阿拉伯语:
$data = array(
'id' => "221212",
'qty' => 1,
'price' => 21.2,
'name' => 'عمر'
);
现在在 Cart.php 类中,我发现了以下内容:
// These are the regular expression rules that we use to validate the product ID and product name
var $product_id_rules = '\.a-z0-9_-';
// alpha-numeric, dashes, underscores, or periods
var $product_name_rules = '\.\:\-_a-z0-9';
// alphanumeric, dashes, underscores, colons or periods
我关心名称规则。显然这是问题所在,因为稍后会进行检查:
if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) {
log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
return FALSE;
}
如何替换名称规则字符串以使用阿拉伯语?我的正则表达式背景很差,所以请帮忙。
谢谢!