fix: remove unnecessary DOCTYPE tags (#1715)

This commit is contained in:
joyqi 2024-01-23 18:30:17 +08:00 committed by GitHub
parent de53b64880
commit e3bdef645d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -60,6 +60,25 @@ class Message
if (trim($this->message) == '') {
return false;
}
// remove the DOCTYPE, avoid using a regexp, so we can save memory
$count = 0;
while (true) {
// Fail if there is an endless loop
if ($count >= 10) {
return false;
}
$pos = strpos($this->message, '<!DOCTYPE');
if ($pos !== false) {
$this->message = substr($this->message, 0, $pos)
. substr($this->message, strpos($this->message, '>', $pos) + 1);
$count ++;
} else {
break;
}
}
$parser = xml_parser_create();
// Set XML parser to take the case of tags in to account
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);

View File

@ -93,7 +93,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
* @property int $commentsPostInterval
* @property string $commentsHTMLTagAllowed
* @property bool $allowRegister
* @property bool $allowXmlRpc
* @property int $allowXmlRpc
* @property int $postsListSize
* @property bool $feedFullText
* @property int $defaultCategory