mdx close tag is not necessary.

dictionary marker should make sure the dictionary is ok.

If not ,the modern browser is the last protection
This commit is contained in:
xiaoyifang 2022-03-12 19:20:01 +08:00
parent ab1b525f12
commit c0eae69aec

38
mdx.cc
View file

@ -1009,26 +1009,26 @@ void MdxDictionary::loadArticle( uint32_t offset, string & articleText, bool noF
if( !noFilter )
article = filterResource( articleId, article );
// Check for unclosed <span> and <div>
QRegularExpression openTagsRx( "<\\s*span\\b", QRegularExpression::PatternOption::CaseInsensitiveOption );
int openTags = article.count( openTagsRx );
QRegularExpression closeTagRx( "<\\s*/span\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption );
int closedTags = article.count( closeTagRx );
while( openTags > closedTags )
{
article += "</span>";
closedTags += 1;
}
//// Check for unclosed <span> and <div>
//QRegularExpression openTagsRx( "<\\s*span\\b", QRegularExpression::PatternOption::CaseInsensitiveOption );
//int openTags = article.count( openTagsRx );
//QRegularExpression closeTagRx( "<\\s*/span\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption );
//int closedTags = article.count( closeTagRx );
//while( openTags > closedTags )
//{
// article += "</span>";
// closedTags += 1;
//}
QRegularExpression openDivRx( "<\\s*div\\b", QRegularExpression::PatternOption::CaseInsensitiveOption );
openTags = article.count( openDivRx );
QRegularExpression closeDivRx( "<\\s*/div\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption );
closedTags = article.count( closeDivRx );
while( openTags > closedTags )
{
article += "</div>";
closedTags += 1;
}
//QRegularExpression openDivRx( "<\\s*div\\b", QRegularExpression::PatternOption::CaseInsensitiveOption );
//openTags = article.count( openDivRx );
//QRegularExpression closeDivRx( "<\\s*/div\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption );
//closedTags = article.count( closeDivRx );
//while( openTags > closedTags )
//{
// article += "</div>";
// closedTags += 1;
//}
articleText = string( article.toUtf8().constData() );
}