summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/inc/strings.hrc1
-rw-r--r--cui/source/options/personalization.cxx21
2 files changed, 22 insertions, 0 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index 06347dea6bcc..71ff45488568 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -371,6 +371,7 @@
#define RID_SVXSTR_SEARCHERROR NC_("RID_SVXSTR_SEARCHERROR", "Cannot open %1, please try again later.")
#define RID_SVXSTR_NORESULTS NC_("RID_SVXSTR_NORESULTS", "No results found.")
#define RID_SVXSTR_APPLYPERSONA NC_("RID_SVXSTR_APPLYPERSONA", "Applying Theme...")
+#define RID_SVXSTR_INVALIDPERSONAURL NC_("RID_SVXSTR_INVALIDPERSONAURL", "Please enter a valid theme address or a search term.")
#define RID_SVXSTR_TABLE_PRESET_NONE NC_("RID_SVXSTR_TABLE_PRESET_NONE", "Set No Borders")
#define RID_SVXSTR_TABLE_PRESET_ONLYOUTER NC_("RID_SVXSTR_TABLE_PRESET_ONLYOUTER", "Set Outer Border Only")
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";