mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Aard: Better isolate the cards from each other; protect against broken HTML
This commit is contained in:
parent
d9bcb2ea43
commit
6a20b9765a
14
aard.cc
14
aard.cc
|
@ -474,7 +474,19 @@ void AardDictionary::loadArticle( quint32 address,
|
||||||
else
|
else
|
||||||
articleText = string( QObject::tr( "Article decoding error" ).toUtf8().constData() );
|
articleText = string( QObject::tr( "Article decoding error" ).toUtf8().constData() );
|
||||||
|
|
||||||
articleText = "<div class=\"aard\">" + articleText + "</div>";
|
// See Issue #271: A mechanism to clean-up invalid HTML cards.
|
||||||
|
string cleaner = "</font>""</font>""</font>""</font>""</font>""</font>"
|
||||||
|
"</font>""</font>""</font>""</font>""</font>""</font>"
|
||||||
|
"</b></b></b></b></b></b></b></b>"
|
||||||
|
"</i></i></i></i></i></i></i></i>"
|
||||||
|
"</a></a></a></a></a></a></a></a>";
|
||||||
|
|
||||||
|
static QRegExp self_closing_divs( "(<div\\s[^>]*)/>", Qt::CaseInsensitive ); // <div ... />
|
||||||
|
|
||||||
|
articleText = string( "<div class=\"aard\">" )
|
||||||
|
// protect against <div/> which breaks formatting
|
||||||
|
+ QString::fromUtf8( ( articleText ).c_str() ).replace( self_closing_divs, "\\1></div>").toUtf8().data()
|
||||||
|
+ cleaner + "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString const& AardDictionary::getDescription()
|
QString const& AardDictionary::getDescription()
|
||||||
|
|
Loading…
Reference in a new issue