Clean up HTML filtering and emoji encoding #2631

This commit is contained in:
Kijin Sung 2025-12-17 17:53:39 +09:00
parent 307661b57b
commit cc17bbe05a
4 changed files with 46 additions and 28 deletions

View file

@ -811,24 +811,31 @@ class DocumentController extends Document
}
// if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_inserted || isset($obj->allow_html) || isset($obj->use_html))
if (!$manual_inserted || isset($obj->allow_html) || isset($obj->use_html))
{
$obj->content = EditorModel::converter($obj, 'document');
}
// Remove iframe and script if not a top adminisrator in the session.
if($logged_info->is_admin != 'Y')
if ($logged_info->is_admin !== 'Y')
{
$obj->content = removeHackTag($obj->content);
$obj->content = Rhymix\Framework\Filters\HTMLFilter::clean((string)$obj->content);
}
// Fix encoding of non-BMP UTF-8 characters.
if (config('db.master.charset') !== 'utf8mb4')
{
$obj->title = utf8_mbencode($obj->title);
$obj->content = utf8_mbencode($obj->content);
}
// An error appears if both log-in info and user name don't exist.
if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1, 'msg_invalid_request');
// Fix encoding of non-BMP UTF-8 characters.
$obj->title = utf8_mbencode($obj->title);
$obj->content = utf8_mbencode($obj->content);
if (!$logged_info->member_srl && !$obj->nick_name)
{
return new BaseObject(-1, 'msg_invalid_request');
}
// Set lang_code to the current user's language
$obj->lang_code = Context::getLangType();
// begin transaction
@ -1167,14 +1174,17 @@ class DocumentController extends Document
}
// Remove iframe and script if not a top adminisrator in the session.
if($logged_info->is_admin != 'Y')
if ($logged_info->is_admin !== 'Y')
{
$obj->content = removeHackTag($obj->content);
$obj->content = Rhymix\Framework\Filters\HTMLFilter::clean((string)$obj->content);
}
// Fix encoding of non-BMP UTF-8 characters.
$obj->title = utf8_mbencode($obj->title);
$obj->content = utf8_mbencode($obj->content);
if (config('db.master.charset') !== 'utf8mb4')
{
$obj->title = utf8_mbencode($obj->title);
$obj->content = utf8_mbencode($obj->content);
}
// Begin transaction
$oDB = DB::getInstance();

View file

@ -55,11 +55,10 @@ class DocumentView extends Document
throw new Rhymix\Framework\Exceptions\SecurityViolation;
}
$content = Context::get('content');
if(Context::get('logged_info')->is_admin != 'Y')
$content = (string)Context::get('content');
if (Context::get('logged_info')->is_admin !== 'Y')
{
$content = removeHackTag($content);
$content = Rhymix\Framework\Filters\HTMLFilter::clean($content);
}
// Editor converter