From 6a20b9765a767d884001e57367cb30d97f1ce1d6 Mon Sep 17 00:00:00 2001 From: Tvangeste Date: Thu, 4 Jul 2013 15:58:28 +0200 Subject: [PATCH] Aard: Better isolate the cards from each other; protect against broken HTML --- aard.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/aard.cc b/aard.cc index 2505aeaa..600f2301 100644 --- a/aard.cc +++ b/aard.cc @@ -474,7 +474,19 @@ void AardDictionary::loadArticle( quint32 address, else articleText = string( QObject::tr( "Article decoding error" ).toUtf8().constData() ); - articleText = "
" + articleText + "
"; + // See Issue #271: A mechanism to clean-up invalid HTML cards. + string cleaner = """""""""""" + """""""""""" + "" + "" + ""; + + static QRegExp self_closing_divs( "(]*)/>", Qt::CaseInsensitive ); //
+ + articleText = string( "
" ) + // protect against
which breaks formatting + + QString::fromUtf8( ( articleText ).c_str() ).replace( self_closing_divs, "\\1>
").toUtf8().data() + + cleaner + "
"; } QString const& AardDictionary::getDescription()