From 5312c981f791cc541dc50c42695e93f85042e792 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 26 Jun 2021 22:42:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=AE=9D=E9=80=80=E6=AC=BE=E5=8F=AF=E8=83=BD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98(?= =?UTF-8?q?=E4=BE=8B=E5=A6=82return=5Furl=E7=A9=BA=E5=80=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gateways/Alipay/AliBaseObject.php | 2 +- src/Helpers/ArrayUtil.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Gateways/Alipay/AliBaseObject.php b/src/Gateways/Alipay/AliBaseObject.php index 673e63eb..38ea9a4d 100644 --- a/src/Gateways/Alipay/AliBaseObject.php +++ b/src/Gateways/Alipay/AliBaseObject.php @@ -197,7 +197,7 @@ protected function buildParams(string $method, array $requestParams) $params = ArrayUtil::arraySort($params); try { - $signStr = ArrayUtil::createLinkString($params); + $signStr = ArrayUtil::createLinkString($params, true); //支付宝签名对于空值会抛弃 $signType = self::$config->get('sign_type', ''); $params['sign'] = $this->makeSign($signType, $signStr); diff --git a/src/Helpers/ArrayUtil.php b/src/Helpers/ArrayUtil.php index 2d9cdd56..e75bc512 100644 --- a/src/Helpers/ArrayUtil.php +++ b/src/Helpers/ArrayUtil.php @@ -94,10 +94,11 @@ public static function arraySort(array $param) /** * 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 * @param array $para 需要拼接的数组 + * @param bool $ignoreEmptyStr 是否忽略空字符串 * @return string * @throws \Exception */ - public static function createLinkString($para) + public static function createLinkString($para, $ignoreEmptyStr = false) { if (!is_array($para)) { throw new \Exception('必须传入数组参数'); @@ -109,7 +110,7 @@ public static function createLinkString($para) if (is_array($val)) { continue; } - + if ($ignoreEmptyStr && $val == '') continue; $arg .= $key . '=' . urldecode($val) . '&'; } //去掉最后一个&字符 From b063126f1bc577711ff4bf41bb19fe973753facf Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 26 Jun 2021 22:51:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0php7.4=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Helpers/ArrayUtil.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Helpers/ArrayUtil.php b/src/Helpers/ArrayUtil.php index e75bc512..05e78357 100644 --- a/src/Helpers/ArrayUtil.php +++ b/src/Helpers/ArrayUtil.php @@ -117,9 +117,10 @@ public static function createLinkString($para, $ignoreEmptyStr = false) $arg && $arg = substr($arg, 0, -1); //如果存在转义字符,那么去掉转义 - if (get_magic_quotes_gpc()) { - $arg = stripslashes($arg); - } + //php7.4 废弃了get_magic_quotes_gpc +// if (get_magic_quotes_gpc()) { +// $arg = stripslashes($arg); +// } return $arg; } From f290aefb5ae91c5626140f0cbcc03d2cdd0f9c5b Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 27 Jun 2021 15:02:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=87=87=E7=94=A8=E7=8E=B0=E6=9C=89?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E5=A4=84=E7=90=86return=5F?= =?UTF-8?q?url=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gateways/Alipay/AliBaseObject.php | 4 ++-- src/Helpers/ArrayUtil.php | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Gateways/Alipay/AliBaseObject.php b/src/Gateways/Alipay/AliBaseObject.php index 38ea9a4d..9cacac40 100644 --- a/src/Gateways/Alipay/AliBaseObject.php +++ b/src/Gateways/Alipay/AliBaseObject.php @@ -197,7 +197,7 @@ protected function buildParams(string $method, array $requestParams) $params = ArrayUtil::arraySort($params); try { - $signStr = ArrayUtil::createLinkString($params, true); //支付宝签名对于空值会抛弃 + $signStr = ArrayUtil::createLinkString($params); $signType = self::$config->get('sign_type', ''); $params['sign'] = $this->makeSign($signType, $signStr); @@ -231,7 +231,7 @@ private function getBaseData(string $method, array $bizContent) // 'app_auth_token' => '', // 暂时不用 'biz_content' => json_encode($bizContent, JSON_UNESCAPED_UNICODE), ]; - $requestData = ArrayUtil::paraFilter($requestData); + $requestData = ArrayUtil::paraFilter($requestData); //支付宝签名对于空值会抛弃 return ArrayUtil::arraySort($requestData); } diff --git a/src/Helpers/ArrayUtil.php b/src/Helpers/ArrayUtil.php index 05e78357..f9f4c21e 100644 --- a/src/Helpers/ArrayUtil.php +++ b/src/Helpers/ArrayUtil.php @@ -94,11 +94,10 @@ public static function arraySort(array $param) /** * 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 * @param array $para 需要拼接的数组 - * @param bool $ignoreEmptyStr 是否忽略空字符串 * @return string * @throws \Exception */ - public static function createLinkString($para, $ignoreEmptyStr = false) + public static function createLinkString($para) { if (!is_array($para)) { throw new \Exception('必须传入数组参数'); @@ -110,7 +109,6 @@ public static function createLinkString($para, $ignoreEmptyStr = false) if (is_array($val)) { continue; } - if ($ignoreEmptyStr && $val == '') continue; $arg .= $key . '=' . urldecode($val) . '&'; } //去掉最后一个&字符