From c223e5ff859171adab1597025b30ec2501fc5771 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 4 Jan 2013 23:09:18 +0100 Subject: Personas: More robust Persona URL handling. Change-Id: I55fa2570decd52e978747e589887f2fe972812c8 --- cui/source/options/personalization.cxx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'cui/source/options') diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 7d31b0fa4cc0..ae8f60572f3d 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -71,7 +71,14 @@ OUString SelectPersonaDialog::GetPersonaURL() const return OUString(); } - return aText; + // canonicalize the URL + OUString aPersona( "persona/" ); + sal_Int32 nPersona = aText.lastIndexOf( aPersona ); + + if ( nPersona < 0 ) + return OUString(); + + return "http://www.getpersonas.com/persona/" + aText.copy( nPersona + aPersona.getLength() ); } IMPL_LINK( SelectPersonaDialog, VisitPersonas, PushButton*, /*pButton*/ ) @@ -236,7 +243,7 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ ) while ( aDialog.Execute() == RET_OK ) { OUString aURL( aDialog.GetPersonaURL() ); - if ( aURL != "" ) + if ( !aURL.isEmpty() ) { if ( CopyPersonaToGallery( aURL ) ) m_pOwnPersona->Check(); @@ -312,7 +319,14 @@ bool SvxPersonalizationTabPage::CopyPersonaToGallery( const OUString &rURL ) if ( !xFileAccess.is() ) return false; - uno::Reference< io::XInputStream > xStream( xFileAccess->openFileRead( rURL ), uno::UNO_QUERY ); + uno::Reference< io::XInputStream > xStream; + try { + xStream = xFileAccess->openFileRead( rURL ); + } + catch (...) + { + return false; + } if ( !xStream.is() ) return false; -- cgit v1.2.3