This commit is contained in:
Default
2025-04-23 14:59:27 +08:00
parent 7f89da9839
commit a898202a84
3 changed files with 21 additions and 11 deletions

View File

@@ -847,19 +847,26 @@ namespace {
if ($intReturnCode === 0) {
return true;
} else {
echo "Conversion failed: " . implode("\n", $strOutput);
return false;
}
}
function ensureUtf8(string $input): string
/**
* Ensures the input string is valid UTF-8, discarding invalid characters
*
* @param string $strInput
* @return string
*/
function ensureUtf8(string $strInput): string
{
// 检查是否为有效的 UTF-8
if (mb_check_encoding($input, 'UTF-8')) {
return $input; // 已经是有效的 UTF-8
if (mb_check_encoding($strInput, 'UTF-8')) {
return $strInput;
}
// 尝试将非 UTF-8 转换为 UTF-8忽略无效字符
return iconv('UTF-8', 'UTF-8//IGNORE', $input);
// 设置无效字符直接丢弃
mb_substitute_character('none');
// 转换为 UTF-8丢弃无效字符
return mb_convert_encoding($strInput, 'UTF-8', 'UTF-8');
}
}

View File

@@ -53,11 +53,13 @@ class ChapterService
$intCacheLifeTime = (int)$arrParams['cache_life'] ?? 0;
$arrFilter = [
'n_id' => $intNId,
'c_page' => 0,
];
$arrFilter['n_id'] = $intNId;
if ($intNId > 0) {
$arrFilter['n_id'] = $intNId;
}
$arrSort = [];

View File

@@ -88,7 +88,8 @@ class VideoInfoPage extends BasePage
$arrVideo['vod_director'] = explode(',', $arrVideo['vod_director']);
$arrVideo['vod_class'] = explode(',', $arrVideo['vod_class']);
$arrVideo['vod_content'] = trim($arrVideo['vod_content']);
$arrVideo['vod_content'] = trim($arrVideo['vod_content'], '\ ');
$arrVideo['vod_content'] = mb_rtrim($arrVideo['vod_content'], '\ ');
$arrVideo['vod_content'] = ensureUtf8($arrVideo['vod_content']);
foreach ($arrVideo as $strKey => $mixedVal) {
@@ -165,7 +166,7 @@ class VideoInfoPage extends BasePage
'v_director' => $arrPageVideo['v_director'],
'v_class' => $arrPageVideo['v_class'],
'v_letter' => $arrPageVideo['v_letter'],
// 'v_pic' => $arrPageVideo['v_pic'],
'v_pic' => '',
'v_lang' => $arrPageVideo['v_lang'],
'v_area' => $arrPageVideo['v_area'],
'v_year' => $arrPageVideo['v_year'],