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 ) if( !noFilter )
article = filterResource( articleId, article ); article = filterResource( articleId, article );
// Check for unclosed <span> and <div> //// Check for unclosed <span> and <div>
QRegularExpression openTagsRx( "<\\s*span\\b", QRegularExpression::PatternOption::CaseInsensitiveOption ); //QRegularExpression openTagsRx( "<\\s*span\\b", QRegularExpression::PatternOption::CaseInsensitiveOption );
int openTags = article.count( openTagsRx ); //int openTags = article.count( openTagsRx );
QRegularExpression closeTagRx( "<\\s*/span\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption ); //QRegularExpression closeTagRx( "<\\s*/span\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption );
int closedTags = article.count( closeTagRx ); //int closedTags = article.count( closeTagRx );
while( openTags > closedTags ) //while( openTags > closedTags )
{ //{
article += "</span>"; // article += "</span>";
closedTags += 1; // closedTags += 1;
} //}
QRegularExpression openDivRx( "<\\s*div\\b", QRegularExpression::PatternOption::CaseInsensitiveOption ); //QRegularExpression openDivRx( "<\\s*div\\b", QRegularExpression::PatternOption::CaseInsensitiveOption );
openTags = article.count( openDivRx ); //openTags = article.count( openDivRx );
QRegularExpression closeDivRx( "<\\s*/div\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption ); //QRegularExpression closeDivRx( "<\\s*/div\\s*>", QRegularExpression::PatternOption::CaseInsensitiveOption );
closedTags = article.count( closeDivRx ); //closedTags = article.count( closeDivRx );
while( openTags > closedTags ) //while( openTags > closedTags )
{ //{
article += "</div>"; // article += "</div>";
closedTags += 1; // closedTags += 1;
} //}
articleText = string( article.toUtf8().constData() ); articleText = string( article.toUtf8().constData() );
} }