Browse Source

优化站内相对链接判断

优化后台链接跳转
Karson 1 year ago
parent
commit
4eaae6ac4e
2 changed files with 3 additions and 2 deletions
  1. 2 1
      application/admin/controller/Index.php
  2. 1 1
      application/common.php

+ 2 - 1
application/admin/controller/Index.php

@@ -66,7 +66,8 @@ class Index extends Backend
      */
     public function login()
     {
-        $url = $this->request->get('url', 'index/index', 'url_clean');
+        $url = $this->request->get('url', '', 'url_clean');
+        $url = $url ?: 'index/index';
         if ($this->auth->isLogin()) {
             $this->success(__("You've logged in, do not login again"), $url);
         }

+ 1 - 1
application/common.php

@@ -514,7 +514,7 @@ if (!function_exists('check_url_allowed')) {
         }
 
         //如果是站内相对链接则允许
-        if (preg_match("/^[\/a-z][a-z0-9][a-z0-9\.\/]+\$/i", $url) && substr($url, 0, 2) !== '//') {
+        if (preg_match("/^[\/a-z][a-z0-9][a-z0-9\.\/]+((\?|#).*)?\$/i", $url) && substr($url, 0, 2) !== '//') {
             return true;
         }