From f73a3f852ef759596f5aa4a2fc5e9be9e2840fc4 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sat, 27 Aug 2022 22:45:19 +0100 Subject: [PATCH] Hyperlinks: Fix URL validation for https --- common/eda_text.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index f1c99bbccd..044fe8aba2 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -981,9 +981,19 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn bool EDA_TEXT::ValidateHyperlink( const wxString& aURL ) { - wxURL url; + if( aURL.IsEmpty() || IsGotoPageHref( aURL ) ) + return true; - return aURL.IsEmpty() || url.SetURL( aURL ) == wxURL_NOERR || IsGotoPageHref( aURL ); + // Limit valid urls to 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 false; }