summaryrefslogtreecommitdiff
path: root/cui/source
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@pardus.org.tr>2018-10-08 14:43:12 +0300
committerMuhammet Kara <muhammet.kara@pardus.org.tr>2018-10-09 19:41:09 +0200
commite59ea346d31d416e61b963648e78c5c7f13d8551 (patch)
treec3f204baa870cd7a5410f5029928d7698d87b91c /cui/source
parent1b8886ad7744fc48e09bb7379d8ad8e75bb3084d (diff)
tdf#101629: Handle invalid urls and search strings for Personas
Change-Id: I9666aa9f323e53ef394121acdef146866d2cc696 Reviewed-on: https://gerrit.libreoffice.org/61529 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@pardus.org.tr>
Diffstat (limited to 'cui/source')
-rw-r--r--cui/source/options/personalization.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index 0c88f9adf325..ae314e1019c8 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -284,14 +284,35 @@ IMPL_LINK( SelectPersonaDialog, SearchPersonas, Button*, pButton, void )
if( searchTerm.isEmpty( ) )
return;
+ // Direct url of a persona given
if ( searchTerm.startsWith( "https://addons.mozilla.org/" ) )
{
OUString sSlug = searchTerm.getToken( 6, '/' );
+ // Check if we got the slug
+ if ( sSlug.isEmpty() )
+ {
+ SolarMutexGuard aGuard;
+ OUString sError = CuiResId( RID_SVXSTR_INVALIDPERSONAURL );
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
+ VclMessageType::Error, VclButtonsType::Ok,
+ sError));
+ xBox->run();
+ return;
+ }
+
+ // Remove invalid characters
+ searchTerm = searchTerm.replaceAll("?", "");
+
m_pSearchThread = new SearchAndParseThread( this, sSlug, true );
}
+ // Search term given
else
{
+ // Remove invalid characters
+ searchTerm = searchTerm.replaceAll("/", "");
+ searchTerm = searchTerm.replaceAll("?", "");
+
// 15 results so that invalid and duplicate search results whose names, textcolors etc. are null can be skipped
OUString rSearchURL = "https://addons.mozilla.org/api/v3/addons/search/?q=" + searchTerm + "&type=persona&page_size=15";