修改了商品属性,因为有个尺寸的属性例如 (1.2x2.3)需要有特殊字符 . ,想请问下这里为什么要做这些字符串的限制呢,如果我把这个限制删了会出现什么问题呢?
因为分类侧栏要使用这些属性做属性过滤,选择的属性是通过url get param传递的
而url中对参数的字符是有限制的,因此,对于属性的字符也进行了限制。只能使用里面的相应字符。
/** * @property $strVal | String * 把属性值转换成url格式的字符串,用于生成url. */ protected function actionAttrValConvertUrlStr($strVal) { if ($strVal) { // if (!preg_match('/^[A-Za-z0-9-_ &]+$/', $strVal)) { // throw new InvalidValueException('"'.$strVal .'":contain special str , you can only contain special string [A-Za-z0-9-_ &]'); // } $strVal = urlencode($strVal); $convert = $this->strUrlRelation(); foreach ($convert as $originStr => $nStr) { $strVal = str_replace($originStr, $nStr, $strVal); } return $strVal; } }
如果我把这个函数重写成这样,就是不作判断直接用url转义应该不会出现什么问题吧,怕其他方面会出问题
@xiaoming #2楼 你测试下试试吧,主要看分类侧栏属性过滤是否会出问题。
@Fecshop #3楼 要是只是侧栏使用到的话暂时没有想到会有什么问题出现 ,应该没什么问题 ,简单测试了一下可以的
嗯,多测试看看