Treat user fields starting with http:// or https:// as a URL.

Fixes: lp:1785879
* https://bugs.launchpad.net/kicad/+bug/1785879
This commit is contained in:
Jeff Young 2018-08-08 01:41:56 +01:00
parent 9b44100e04
commit 99ed476de1
1 changed files with 9 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include <template_fieldnames.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/grid_text_button_helpers.h>
#include <wx/regex.h>
#include "eda_doc.h"
@ -175,6 +176,8 @@ bool FIELDS_GRID_TABLE<T>::CanSetValueAs( int aRow, int aCol, const wxString& aT
template <class T>
wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
{
static wxRegEx httpPrefix( wxT( "https?:\/\/" ) );
switch( aCol )
{
case FDC_NAME:
@ -224,6 +227,12 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
m_urlAttr->IncRef();
return m_urlAttr;
}
else if( httpPrefix.Matches( GetValue( aRow, aCol ) ) )
{
// Treat any user-defined field that starts with http:// or https:// as a URL
m_urlAttr->IncRef();
return m_urlAttr;
}
return nullptr;
case FDC_TEXT_SIZE: