Skip to content

Commit 51c2ba1

Browse files
committed
[plugin manager] Clean up description and about text by stripping HTML code
1 parent 75e7fed commit 51c2ba1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/app/pluginmanager/qgspluginmanager.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ void QgsPluginManager::reloadModelData()
541541
mypDetailItem->setData( error, PLUGIN_ERROR_ROLE );
542542
mypDetailItem->setData( description, PLUGIN_DESCRIPTION_ROLE );
543543
mypDetailItem->setData( author, PLUGIN_AUTHOR_ROLE );
544-
mypDetailItem->setData( it->value( QStringLiteral( "tags" ) ).toLower(), PLUGIN_TAGS_ROLE );
544+
mypDetailItem->setData( it->value( QStringLiteral( "tags" ) ), PLUGIN_TAGS_ROLE );
545545
mypDetailItem->setData( it->value( QStringLiteral( "downloads" ) ).rightJustified( 10, '0' ), PLUGIN_DOWNLOADS_ROLE );
546546
mypDetailItem->setData( it->value( QStringLiteral( "average_vote" ) ), PLUGIN_VOTE_ROLE );
547547
mypDetailItem->setData( it->value( QStringLiteral( "deprecated" ) ), PLUGIN_ISDEPRECATED_ROLE );
@@ -862,13 +862,21 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item )
862862
html += QStringLiteral( "<img src=\"%1\" style=\"float:right;max-width:64px;max-height:64px;\">" ).arg( iconPath );
863863
}
864864

865-
html += QStringLiteral( "<h1>%1</h1>" ).arg( metadata->value( QStringLiteral( "name" ) ) );
865+
QRegularExpression stripHtml = QRegularExpression( QStringLiteral( "&lt;[^\\s].*?&gt;" ) );
866866

867-
html += QStringLiteral( "<h3>%1</h3>" ).arg( metadata->value( QStringLiteral( "description" ) ) );
867+
QString name = metadata->value( QStringLiteral( "name" ) );
868+
name = name.remove( stripHtml );
869+
html += QStringLiteral( "<h1>%1</h1>" ).arg( name );
870+
871+
QString description = metadata->value( QStringLiteral( "description" ) );
872+
description = description.remove( stripHtml );
873+
html += QStringLiteral( "<h3>%1</h3>" ).arg( description );
868874

869875
if ( ! metadata->value( QStringLiteral( "about" ) ).isEmpty() )
870876
{
871877
QString about = metadata->value( QStringLiteral( "about" ) );
878+
// The regular expression insures that a new line will be present after the closure of a paragraph tag (i.e. </p>)
879+
about = about.replace( QRegularExpression( QStringLiteral( "&lt;\\/p&gt;([^\\n])" ) ), QStringLiteral( "&lt;/p&gt;\n\\1" ) ).remove( stripHtml );
872880
html += about.replace( '\n', QLatin1String( "<br/>" ) );
873881
html += QLatin1String( "<br/><br/>" );
874882
}
@@ -909,7 +917,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item )
909917
}
910918
if ( ! metadata->value( QStringLiteral( "tags" ) ).isEmpty() )
911919
{
912-
QStringList tags = metadata->value( QStringLiteral( "tags" ) ).split( ',' );
920+
QStringList tags = metadata->value( QStringLiteral( "tags" ) ).toLower().split( ',' );
913921
for ( auto tag = tags.begin(); tag != tags.end(); ++tag )
914922
{
915923
*tag = QStringLiteral( "<a href='rpc2://search.tag/%1/'>%1</a>" ).arg( ( *tag ).trimmed() );

0 commit comments

Comments
 (0)