过滤特殊字符
Showing
1 changed file
with
15 additions
and
1 deletions
| ... | @@ -174,11 +174,14 @@ class BaseController extends Controller | ... | @@ -174,11 +174,14 @@ class BaseController extends Controller |
| 174 | } | 174 | } |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | //针对外显-特殊处理 | 177 | //1.针对外显-特殊处理 |
| 178 | if (strpos($params, 'brandShowName[]') !== false) { | 178 | if (strpos($params, 'brandShowName[]') !== false) { |
| 179 | $params = str_replace('brandShowName[]', 'brandShowName{}', $params); | 179 | $params = str_replace('brandShowName[]', 'brandShowName{}', $params); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | //2.去除特殊字符 | ||
| 183 | $params = $this->removeSpecialCharacter($params); | ||
| 184 | |||
| 182 | file_put_contents('1.log', $params."\r\n\r\n", FILE_APPEND); | 185 | file_put_contents('1.log', $params."\r\n\r\n", FILE_APPEND); |
| 183 | 186 | ||
| 184 | Log::channel('api')->info(__METHOD__.':签名参数', [ | 187 | Log::channel('api')->info(__METHOD__.':签名参数', [ |
| ... | @@ -192,6 +195,17 @@ class BaseController extends Controller | ... | @@ -192,6 +195,17 @@ class BaseController extends Controller |
| 192 | } | 195 | } |
| 193 | 196 | ||
| 194 | /** | 197 | /** |
| 198 | * 去除特殊字符 | ||
| 199 | * @param string $params | ||
| 200 | * @return string | ||
| 201 | */ | ||
| 202 | private function removeSpecialCharacter(string $params): string | ||
| 203 | { | ||
| 204 | $character = ['\u005C','\u00A0','\u2028','\u2029','\uFEFF','\u0008','\u0009','\u000A','\u000B','\u000C','\u000D','\u0022','\u0027']; | ||
| 205 | return str_replace($character, '', $params); | ||
| 206 | } | ||
| 207 | |||
| 208 | /** | ||
| 195 | * 签名需要,递归处理子数组中Int型数字转换成字符串 | 209 | * 签名需要,递归处理子数组中Int型数字转换成字符串 |
| 196 | * @param array $array | 210 | * @param array $array |
| 197 | * @return array | 211 | * @return array | ... | ... |
-
Please register or sign in to post a comment