File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/plugin/admin/app/common Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -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 }
You can’t perform that action at this time.
0 commit comments