From 0ee281b800559813e96d8bb2dc3ffb964eeb6cb7 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Thu, 18 Nov 2021 14:37:26 +0800 Subject: [PATCH] * Fix version of api request. --- framework/api/router.class.php | 16 +++------------- framework/base/helper.class.php | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/framework/api/router.class.php b/framework/api/router.class.php index 73b2f0df93..9d9db4b96b 100644 --- a/framework/api/router.class.php +++ b/framework/api/router.class.php @@ -82,22 +82,12 @@ class api extends router $this->httpMethod = strtolower($_SERVER['REQUEST_METHOD']); - if(!empty($_SERVER['PATH_INFO'])) - { - $this->path = rtrim($_SERVER['PATH_INFO'], '/'); - } - else - { - $this->path = rtrim((strpos($_SERVER['REQUEST_URI'], '?') > 0 ? strstr($_SERVER['REQUEST_URI'], '?', true) : $_SERVER['REQUEST_URI']), '/'); - } - $dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'); + $this->path = rtrim((strpos($_SERVER['REQUEST_URI'], '?') > 0 ? strstr($_SERVER['REQUEST_URI'], '?', true) : $_SERVER['REQUEST_URI']), '/'); if($dir != '' and strpos($this->path, $dir) === 0) $this->path = substr($this->path, strlen($dir)); - $subPos = strpos($this->path, '/', 1); - - $this->version = $subPos ? substr($this->path, 1, $subPos - 1) : ''; - $this->path = $subPos ? substr($this->path, $subPos) : $this->path; + $subPos = $dir ? strpos($dir, '/', 1) : 0; + $this->version = $subPos ? substr($dir, $subPos + 1) : ''; $this->loadApiLang(); } diff --git a/framework/base/helper.class.php b/framework/base/helper.class.php index 93399c0fd1..78a201d648 100644 --- a/framework/base/helper.class.php +++ b/framework/base/helper.class.php @@ -894,6 +894,6 @@ function isHttps() */ function htmlSpecialString($string, $flags = '', $encoding = 'UTF-8') { - if(!$flags) $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401; + if(!$flags) $flags = defined('ENT_SUBSTITUTE') ? ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 : ENT_QUOTES; return htmlspecialchars($string, $flags, $encoding); }