diff --git a/SECURITY.md b/SECURITY.md index 75621867..09becb44 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,3 +1,3 @@ # Security Policy -Vulnerabilities can be reported by emailing info@joyqi.com +Vulnerabilities can be reported by emailing security@typecho.org diff --git a/var/Widget/Base/Comments.php b/var/Widget/Base/Comments.php index 888d591e..f38a6367 100644 --- a/var/Widget/Base/Comments.php +++ b/var/Widget/Base/Comments.php @@ -79,16 +79,16 @@ class Comments extends Base implements QueryInterface, RowFilterInterface, Prima $insertStruct = [ 'cid' => $rows['cid'], 'created' => empty($rows['created']) ? $this->options->time : $rows['created'], - 'author' => Common::strBy($rows['author']), + 'author' => Common::strBy($rows['author'] ?? null), 'authorId' => empty($rows['authorId']) ? 0 : $rows['authorId'], 'ownerId' => empty($rows['ownerId']) ? 0 : $rows['ownerId'], - 'mail' => Common::strBy($rows['mail']), - 'url' => Common::strBy($rows['url']), - 'ip' => Common::strBy($rows['ip'], $this->request->getIp()), - 'agent' => Common::strBy($rows['agent'], $this->request->getAgent()), - 'text' => Common::strBy($rows['text']), - 'type' => Common::strBy($rows['type'], 'comment'), - 'status' => Common::strBy($rows['status'], 'approved'), + 'mail' => Common::strBy($rows['mail'] ?? null), + 'url' => Common::strBy($rows['url'] ?? null), + 'ip' => Common::strBy($rows['ip'] ?? null, $this->request->getIp()), + 'agent' => Common::strBy($rows['agent'] ?? null, $this->request->getAgent()), + 'text' => Common::strBy($rows['text'] ?? null), + 'type' => Common::strBy($rows['type'] ?? null, 'comment'), + 'status' => Common::strBy($rows['status'] ?? null, 'approved'), 'parent' => empty($rows['parent']) ? 0 : $rows['parent'], ]; @@ -136,11 +136,11 @@ class Comments extends Base implements QueryInterface, RowFilterInterface, Prima /** 构建插入结构 */ $preUpdateStruct = [ - 'author' => Common::strBy($rows['author']), - 'mail' => Common::strBy($rows['mail']), - 'url' => Common::strBy($rows['url']), - 'text' => Common::strBy($rows['text']), - 'status' => Common::strBy($rows['status'], 'approved'), + 'author' => Common::strBy($rows['author'] ?? null), + 'mail' => Common::strBy($rows['mail'] ?? null), + 'url' => Common::strBy($rows['url'] ?? null), + 'text' => Common::strBy($rows['text'] ?? null), + 'status' => Common::strBy($rows['status'] ?? null, 'approved'), ]; $updateStruct = []; diff --git a/var/Widget/Base/Contents.php b/var/Widget/Base/Contents.php index eca52a9d..b8f59545 100644 --- a/var/Widget/Base/Contents.php +++ b/var/Widget/Base/Contents.php @@ -133,13 +133,13 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima ? null : htmlspecialchars($rows['title']), 'created' => empty($rows['created']) ? $this->options->time : $rows['created'], 'modified' => $this->options->time, - 'text' => Common::strBy($rows['text']), + 'text' => Common::strBy($rows['text'] ?? null), 'order' => empty($rows['order']) ? 0 : intval($rows['order']), 'authorId' => $rows['authorId'] ?? $this->user->uid, - 'template' => Common::strBy($rows['template']), - 'type' => Common::strBy($rows['type'], 'post'), - 'status' => Common::strBy($rows['status'], 'publish'), - 'password' => Common::strBy($rows['password']), + 'template' => Common::strBy($rows['template'] ?? null), + 'type' => Common::strBy($rows['type'] ?? null, 'post'), + 'status' => Common::strBy($rows['status'] ?? null, 'publish'), + 'password' => Common::strBy($rows['password'] ?? null), 'commentsNum' => empty($rows['commentsNum']) ? 0 : $rows['commentsNum'], 'allowComment' => !empty($rows['allowComment']) && 1 == $rows['allowComment'] ? 1 : 0, 'allowPing' => !empty($rows['allowPing']) && 1 == $rows['allowPing'] ? 1 : 0, @@ -156,7 +156,7 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima /** 更新缩略名 */ if ($insertId > 0) { - $this->applySlug(!isset($rows['slug']) || strlen($rows['slug']) === 0 ? null : $rows['slug'], $insertId, $insertStruct['title']); + $this->applySlug(Common::strBy($rows['slug'] ?? null), $insertId, $insertStruct['title']); } return $insertId; @@ -230,11 +230,11 @@ class Contents extends Base implements QueryInterface, RowFilterInterface, Prima 'title' => !isset($rows['title']) || strlen($rows['title']) === 0 ? null : htmlspecialchars($rows['title']), 'order' => empty($rows['order']) ? 0 : intval($rows['order']), - 'text' => Common::strBy($rows['text']), - 'template' => Common::strBy($rows['template']), - 'type' => Common::strBy($rows['type'], 'post'), - 'status' => Common::strBy($rows['status'], 'publish'), - 'password' => Common::strBy($rows['password']), + 'text' => Common::strBy($rows['text'] ?? null), + 'template' => Common::strBy($rows['template'] ?? null), + 'type' => Common::strBy($rows['type'] ?? null, 'post'), + 'status' => Common::strBy($rows['status'] ?? null, 'publish'), + 'password' => Common::strBy($rows['password'] ?? null), 'allowComment' => !empty($rows['allowComment']) && 1 == $rows['allowComment'] ? 1 : 0, 'allowPing' => !empty($rows['allowPing']) && 1 == $rows['allowPing'] ? 1 : 0, 'allowFeed' => !empty($rows['allowFeed']) && 1 == $rows['allowFeed'] ? 1 : 0, diff --git a/var/Widget/Contents/Attachment/Edit.php b/var/Widget/Contents/Attachment/Edit.php index 3b86b2ad..39308b3a 100644 --- a/var/Widget/Contents/Attachment/Edit.php +++ b/var/Widget/Contents/Attachment/Edit.php @@ -95,7 +95,7 @@ class Edit extends Contents implements ActionInterface /** 取出数据 */ $input = $this->request->from('name', 'slug', 'description'); - $input['slug'] = Common::slugName(Common::strBy($input['slug'], $input['name'])); + $input['slug'] = Common::slugName(Common::strBy($input['slug'] ?? null, $input['name'])); $attachment['title'] = $input['name']; $attachment['slug'] = $input['slug']; diff --git a/var/Widget/Metas/Category/Edit.php b/var/Widget/Metas/Category/Edit.php index c9672e1e..906f9d80 100644 --- a/var/Widget/Metas/Category/Edit.php +++ b/var/Widget/Metas/Category/Edit.php @@ -133,7 +133,7 @@ class Edit extends Metas implements ActionInterface /** 取出数据 */ $category = $this->request->from('name', 'slug', 'description', 'parent'); - $category['slug'] = Common::slugName(Common::strBy($category['slug'], $category['name'])); + $category['slug'] = Common::slugName(Common::strBy($category['slug'] ?? null, $category['name'])); $category['type'] = 'category'; $category['order'] = $this->getMaxOrder('category', $category['parent']) + 1; @@ -284,7 +284,7 @@ class Edit extends Metas implements ActionInterface /** 取出数据 */ $category = $this->request->from('name', 'slug', 'description', 'parent'); $category['mid'] = $this->request->get('mid'); - $category['slug'] = Common::slugName(Common::strBy($category['slug'], $category['name'])); + $category['slug'] = Common::slugName(Common::strBy($category['slug'] ?? null, $category['name'])); $category['type'] = 'category'; $current = $this->db->fetchRow($this->select()->where('mid = ?', $category['mid'])); diff --git a/var/Widget/Metas/Tag/Edit.php b/var/Widget/Metas/Tag/Edit.php index ad6d3f16..24aa35ca 100644 --- a/var/Widget/Metas/Tag/Edit.php +++ b/var/Widget/Metas/Tag/Edit.php @@ -132,7 +132,7 @@ class Edit extends Metas implements ActionInterface /** 取出数据 */ $tag = $this->request->from('name', 'slug'); $tag['type'] = 'tag'; - $tag['slug'] = Common::slugName(Common::strBy($tag['slug'], $tag['name'])); + $tag['slug'] = Common::slugName(Common::strBy($tag['slug'] ?? null, $tag['name'])); /** 插入数据 */ $tag['mid'] = $this->insert($tag); @@ -254,7 +254,7 @@ class Edit extends Metas implements ActionInterface /** 取出数据 */ $tag = $this->request->from('name', 'slug', 'mid'); $tag['type'] = 'tag'; - $tag['slug'] = Common::slugName(Common::strBy($tag['slug'], $tag['name'])); + $tag['slug'] = Common::slugName(Common::strBy($tag['slug'] ?? null, $tag['name'])); /** 更新数据 */ $this->update($tag, $this->db->sql()->where('mid = ?', $this->request->filter('int')->get('mid'))); diff --git a/var/Widget/XmlRpc.php b/var/Widget/XmlRpc.php index dd44538c..e74a71f6 100644 --- a/var/Widget/XmlRpc.php +++ b/var/Widget/XmlRpc.php @@ -449,9 +449,9 @@ class XmlRpc extends Contents implements ActionInterface, Hook { /** 开始接受数据 */ $input['name'] = $category['name']; - $input['slug'] = Common::slugName(Common::strBy($category['slug'], $category['name'])); + $input['slug'] = Common::slugName(Common::strBy($category['slug'] ?? null, $category['name'])); $input['parent'] = $category['parent_id'] ?? ($category['parent'] ?? 0); - $input['description'] = Common::strBy($category['description'], $category['name']); + $input['description'] = Common::strBy($category['description'] ?? null, $category['name']); /** 调用已有组件 */ $categoryWidget = CategoryEdit::alloc(null, $input, function (CategoryEdit $category) {