@@ -27,8 +27,8 @@ public static function passwordHash($password, string $algo = PASSWORD_DEFAULT)
2727
2828 /**
2929 * 验证密码哈希
30- * @param $password
31- * @param $hash
30+ * @param string $password
31+ * @param string $hash
3232 * @return bool
3333 */
3434 public static function passwordVerify (string $ password , string $ hash ): bool
@@ -109,7 +109,7 @@ public static function formatBytes($file_size): string
109109 */
110110 public static function pdoQuote ($ var )
111111 {
112- return Util::db ()->getPdo ()->quote ($ var, \ PDO :: PARAM_STR );
112+ return Util::db ()->getPdo ()->quote ($ var );
113113 }
114114
115115 /**
@@ -161,15 +161,23 @@ public static function filterNum($var)
161161 }
162162
163163 /**
164- * 检测是否是合法URL Path
164+ * @desc 检测是否是合法URL Path
165165 * @param $var
166166 * @return string
167167 * @throws BusinessException
168168 */
169169 public static function filterUrlPath ($ var ): string
170170 {
171- if (!is_string ($ var ) || !preg_match ('/^[a-zA-Z0-9_\-\/&?.]+$/ ' , $ var )) {
172- throw new BusinessException ('参数不合法 ' );
171+ if (!is_string ($ var )) {
172+ throw new BusinessException ('参数不合法,地址必须是一个字符串! ' );
173+ }
174+
175+ if (strpos ($ var , 'https:// ' ) === 0 || strpos ($ var , 'http:// ' ) === 0 ) {
176+ if (!filter_var ($ var , FILTER_VALIDATE_URL )) {
177+ throw new BusinessException ('参数不合法,不是合法的URL地址! ' );
178+ }
179+ } elseif (!preg_match ('/^[a-zA-Z0-9_\-\/&?.]+$/ ' , $ var )) {
180+ throw new BusinessException ('参数不合法,不是合法的Path! ' );
173181 }
174182 return $ var ;
175183 }
0 commit comments