From 702eebaa9218e7ca74bebaf7e9d901dd1e8743f0 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 1 Jun 2025 17:58:00 +0900 Subject: [PATCH] Fix undefined values in various modules --- common/legacy.php | 2 +- modules/board/board.controller.php | 15 +++++++++++---- modules/comment/comment.controller.php | 6 +++--- modules/document/document.controller.php | 2 +- modules/editor/editor.model.php | 4 ++-- modules/spamfilter/spamfilter.controller.php | 12 ++++++++++-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/common/legacy.php b/common/legacy.php index e254d38eb..f236ae67b 100644 --- a/common/legacy.php +++ b/common/legacy.php @@ -574,7 +574,7 @@ function zgap($timestamp = null): int */ function ztime($str): ?int { - $len = strlen($str); + $len = strlen($str ?? ''); if (!$len) { return null; diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index a112c190d..fe693d38f 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -61,7 +61,7 @@ class BoardController extends Board // Return error if content conains excessively large data URLs. $inline_data_url_limit = $this->module_info->inline_data_url_limit * 1024; - preg_match_all('!src="\s*(data:[^,]*,[a-z0-9+/=%$!._-]+)!i', (string)$obj->content, $matches); + preg_match_all('!src="\s*(data:[^,]*,[a-z0-9+/=\%\$\!._-]+)!i', (string)$obj->content, $matches); foreach ($matches[1] as $match) { if (strlen($match) > $inline_data_url_limit) @@ -116,7 +116,7 @@ class BoardController extends Board $use_status = explode('|@|', $this->module_info->use_status); // Set status - if(($obj->is_secret == 'Y' || $obj->status == $secret_status) && is_array($use_status) && in_array($secret_status, $use_status)) + if((($obj->is_secret ?? 'N') == 'Y' || $obj->status == $secret_status) && is_array($use_status) && in_array($secret_status, $use_status)) { $obj->status = $secret_status; } @@ -224,7 +224,14 @@ class BoardController extends Board $obj->title_bold = $oDocument->get('title_bold'); } - $obj->reason_update = escape($obj->reason_update); + if (isset($obj->reason_update)) + { + $obj->reason_update = escape($obj->reason_update); + } + else + { + $obj->reason_update = ''; + } } // Update @@ -495,7 +502,7 @@ class BoardController extends Board // Return error if content conains excessively large data URLs. $inline_data_url_limit = ($this->module_info->inline_data_url_limit ?: 64) * 1024; - preg_match_all('!src="\s*(data:[^,]*,[a-z0-9+/=%$!._-]+)!i', (string)$obj->content, $matches); + preg_match_all('!src="\s*(data:[^,]*,[a-z0-9+/=\%\$\!._-]+)!i', (string)$obj->content, $matches); foreach ($matches[1] as $match) { if (strlen($match) > $inline_data_url_limit) diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 95a097a76..3d6c39e32 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -1007,12 +1007,12 @@ class CommentController extends Comment return new BaseObject(-1, 'msg_not_permitted'); } - if($obj->password) + if(!empty($obj->password)) { $obj->password = \Rhymix\Framework\Password::hashPassword($obj->password, \Rhymix\Framework\Password::getBackwardCompatibleAlgorithm()); } - if($obj->homepage) + if(!empty($obj->homepage)) { $obj->homepage = escape($obj->homepage); if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) @@ -1021,7 +1021,7 @@ class CommentController extends Comment } } - if(!$obj->content) + if(!isset($obj->content) || !$obj->content) { $obj->content = $source_obj->get('content'); } diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 9d60b5419..06bb24238 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -1091,7 +1091,7 @@ class DocumentController extends Document } // Hash the password if it exists - if($obj->password) + if (!empty($obj->password)) { $obj->password = \Rhymix\Framework\Password::hashPassword($obj->password, \Rhymix\Framework\Password::getBackwardCompatibleAlgorithm()); } diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 8ca4e2ae4..0e2cf9dcc 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -779,7 +779,7 @@ class EditorModel extends Editor // if not inserted converter, Get converter from skin if (!$converter) { - $converter = self::getSkinConfig($skin)->converter; + $converter = self::getSkinConfig($skin)->converter ?? null; } // if not inserted converter, Check @@ -789,7 +789,7 @@ class EditorModel extends Editor { $converter = 'text'; } - elseif (strpos($type == 'comment' ? $config->sel_comment_editor_colorset : $config->sel_editor_colorset, 'nohtml') !== false) + elseif (strpos($type == 'comment' ? ($config->sel_comment_editor_colorset ?? '') : ($config->sel_editor_colorset ?? ''), 'nohtml') !== false) { $converter = 'text'; } diff --git a/modules/spamfilter/spamfilter.controller.php b/modules/spamfilter/spamfilter.controller.php index 4aacea483..ceea7c0f0 100644 --- a/modules/spamfilter/spamfilter.controller.php +++ b/modules/spamfilter/spamfilter.controller.php @@ -38,7 +38,11 @@ class SpamfilterController extends Spamfilter */ function triggerInsertDocument(&$obj) { - if($_SESSION['avoid_log']) return; + if (!empty($_SESSION['avoid_log'])) + { + return; + } + // Check the login status, login information, and permission $is_logged = Context::get('is_logged'); $logged_info = Context::get('logged_info'); @@ -98,7 +102,11 @@ class SpamfilterController extends Spamfilter */ function triggerInsertComment(&$obj) { - if($_SESSION['avoid_log']) return; + if (!empty($_SESSION['avoid_log'])) + { + return; + } + // Check the login status, login information, and permission $is_logged = Context::get('is_logged'); $logged_info = Context::get('logged_info');