Hyperlinks: Don't forget about file:// protocol

This commit is contained in:
Roberto Fernandez Bautista 2022-08-27 22:56:29 +01:00
parent f73a3f852e
commit a76d1a791d
2 changed files with 20 additions and 4 deletions

View File

@ -984,13 +984,13 @@ bool EDA_TEXT::ValidateHyperlink( const wxString& aURL )
if( aURL.IsEmpty() || IsGotoPageHref( aURL ) )
return true;
// Limit valid urls to http and https for now. Note wxURL doesn't support https
// Limit valid urls to file, http and https for now. Note wxURL doesn't support https
wxURI uri;
if( uri.Create( aURL ) && uri.HasScheme() )
{
wxString scheme = uri.GetScheme();
return scheme == wxT( "http" ) || scheme == wxT( "https" );
return scheme == wxT( "file" ) || scheme == wxT( "http" ) || scheme == wxT( "https" );
}
return false;

View File

@ -139,7 +139,9 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE
}
m_hyperlinkCtrl->Append( wxT( "---------------------" ) );
m_hyperlinkCtrl->Append( wxT( "http(s)://..." ) );
m_hyperlinkCtrl->Append( wxT( "file://..." ) );
m_hyperlinkCtrl->Append( wxT( "http://..." ) );
m_hyperlinkCtrl->Append( wxT( "https://..." ) );
SetupStandardButtons();
Layout();
@ -312,13 +314,27 @@ void DIALOG_TEXT_PROPERTIES::onHyperlinkCombo( wxCommandEvent& aEvent )
{
// user clicked outside dropdown; leave current value
}
else if( sel == m_hyperlinkCtrl->GetCount() - 2 )
else if( sel == m_hyperlinkCtrl->GetCount() - 4 )
{
// separator (and wxWidgets already updated our value to it);
// replace value with that saved in the dropdown event
m_hyperlinkCtrl->ChangeValue( m_lastLink );
m_hyperlinkCtrl->SetSelection( 0, m_hyperlinkCtrl->GetValue().Length() );
}
else if( sel == m_hyperlinkCtrl->GetCount() - 3 )
{
static wxString helper = wxT( "file://" );
m_hyperlinkCtrl->ChangeValue( helper );
m_hyperlinkCtrl->SetInsertionPointEnd();
}
else if( sel == m_hyperlinkCtrl->GetCount() - 2 )
{
static wxString helper = wxT( "http://" );
m_hyperlinkCtrl->ChangeValue( helper );
m_hyperlinkCtrl->SetInsertionPointEnd();
}
else if( sel == m_hyperlinkCtrl->GetCount() - 1 )
{
static wxString helper = wxT( "https://" );