From 2fe1c0f26ecaf49fd2510c19a6b972bd3c92898a Mon Sep 17 00:00:00 2001 From: joyqi Date: Thu, 25 Jan 2024 18:43:41 +0800 Subject: [PATCH] fix request query parsing --- var/Typecho/Request.php | 4 ++-- var/Widget/Metas/Category/Edit.php | 2 +- var/Widget/Upload.php | 2 +- var/Widget/XmlRpc.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php index 6c434f39..6d08d465 100644 --- a/var/Typecho/Request.php +++ b/var/Typecho/Request.php @@ -187,7 +187,7 @@ class Request } } else { $exists = false; - return $default; + return $value ?? $default; } } @@ -545,7 +545,7 @@ class Request $validated = true; foreach ($params as $key => $val) { $param = $this->get($key, null, $exists); - $validated = empty($val) ? $exists : ($val == $param); + $validated = $val === '' ? $exists : ($val === $param); if (!$validated) { break; diff --git a/var/Widget/Metas/Category/Edit.php b/var/Widget/Metas/Category/Edit.php index 906f9d80..7b9b9d85 100644 --- a/var/Widget/Metas/Category/Edit.php +++ b/var/Widget/Metas/Category/Edit.php @@ -224,7 +224,7 @@ class Edit extends Metas implements ActionInterface $submit->input->setAttribute('class', 'btn primary'); $form->addItem($submit); - if (isset($this->request->mid) && 'insert' != $action) { + if ($this->request->is('mid') && 'insert' != $action) { /** 更新模式 */ $meta = $this->db->fetchRow($this->select() ->where('mid = ?', $this->request->mid) diff --git a/var/Widget/Upload.php b/var/Widget/Upload.php index cf474b64..6121beb5 100644 --- a/var/Widget/Upload.php +++ b/var/Widget/Upload.php @@ -316,7 +316,7 @@ class Upload extends Contents implements ActionInterface 'allowFeed' => 1 ]; - if (isset($this->request->cid)) { + if ($this->request->is('cid')) { $cid = $this->request->filter('int')->get('cid'); if ($this->isWriteable($this->db->sql()->where('cid = ?', $cid))) { diff --git a/var/Widget/XmlRpc.php b/var/Widget/XmlRpc.php index 873b25d9..250935e1 100644 --- a/var/Widget/XmlRpc.php +++ b/var/Widget/XmlRpc.php @@ -1753,7 +1753,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook throw new Exception(_t('请求的地址不存在'), 404); } - if (isset($this->request->rsd)) { + if ($this->request->get('rsd') !== null) { echo << @@ -1771,7 +1771,7 @@ class XmlRpc extends Contents implements ActionInterface, Hook EOF; - } elseif (isset($this->request->wlw)) { + } elseif ($this->request->get('wlw') !== null) { echo <<