Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions apps/home/controller/ParserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,15 @@ public function parserSiteLabel($content)
break;
case 'statistical':
if (isset($data->statistical)) {
$content = str_replace($matches[0][$i], filter_html(decode_string($data->statistical)), $content);
$statistical = filter_html(decode_string($data->statistical));
$content = str_replace($matches[0][$i], $this->sanitizePhpOpenTag($statistical), $content);
} else {
$content = str_replace($matches[0][$i], '', $content);
}
case 'copyright':
if (isset($data->copyright)) {
$content = str_replace($matches[0][$i], $this->adjustLabelData($params, decode_string($data->copyright)), $content);
$copyright = $this->adjustLabelData($params, decode_string($data->copyright));
$content = str_replace($matches[0][$i], $this->sanitizePhpOpenTag($copyright), $content);
} else {
$content = str_replace($matches[0][$i], '', $content);
}
Expand All @@ -276,6 +278,15 @@ public function parserSiteLabel($content)
return $content;
}

// 转义 PHP 开标签,防止站点信息被还原为可执行 PHP 代码
protected function sanitizePhpOpenTag($content)
{
if (! is_string($content) || $content === '') {
return $content;
}
return preg_replace('/<\?(?:php|=)?/i', '&lt;?', $content);
}

// 解析公司标签
public function parserCompanyLabel($content)
{
Expand Down Expand Up @@ -4083,4 +4094,4 @@ protected function checkLabelLevel($params)
}
return true;
}
}
}