From ad404c15ca75bebdd07eae616a007386dea752ca Mon Sep 17 00:00:00 2001 From: Lukas Lengler Date: Tue, 13 Aug 2024 12:38:49 +0200 Subject: [PATCH] Fix error when entering correct proxy URLs with ports and proxy schemas Entering correct proxy URLS with ports and one of the following schemas (tcp, udp, unix, udg, ssl, tls) would cause an error (Invalid format given) even though these proxies are correct. Now this issue is resolved and the proxies URLs are valid again. --- ChangeLog | 5 +++++ share/server/core/classes/GlobalMainCfg.php | 2 +- share/server/core/defines/matches.php | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99e3ac392..567663dab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ 1.9.43 +Core: + * FIX: Fix error when entering correct proxy URLs with ports and proxy schemas. + Entering correct proxy URLS with ports and one of the following schemas + (tcp, udp, unix, udg, ssl, tls) would cause an error (Invalid format given) + even though these proxies are correct. 1.9.42 Security: diff --git a/share/server/core/classes/GlobalMainCfg.php b/share/server/core/classes/GlobalMainCfg.php index 50d3daa39..1e3812085 100644 --- a/share/server/core/classes/GlobalMainCfg.php +++ b/share/server/core/classes/GlobalMainCfg.php @@ -179,7 +179,7 @@ public function __construct() { 'http_proxy' => array( 'must' => 0, 'default' => null, - 'match' => MATCH_STRING_URL, + 'match' => MATCH_STRING_PROXY, ), 'http_proxy_auth' => array( 'must' => 0, diff --git a/share/server/core/defines/matches.php b/share/server/core/defines/matches.php index 67de92072..bb520b4ae 100644 --- a/share/server/core/defines/matches.php +++ b/share/server/core/defines/matches.php @@ -40,8 +40,11 @@ define('MATCH_STRING_PATH', '/^[0-9a-z\s_.\-\/\\\]+$/i'); define('MATCH_STRING_PATH_AUTHORISATION', '/^(?!' . DISALLOWED_AUTHORISATION_PATHS . ')[0-9a-z\s_.\-\/\\\]+$/i'); define('MATCH_ALLOWED_URL_SCHEMES', '(http|https)'); -define('MATCH_STRING_URL', '/^(?:' . MATCH_ALLOWED_URL_SCHEMES . ':)?[0-9a-z\s;|+[\]()=%?&_,.\-#@=\/\\\~\{\}]+$/i'); -define('MATCH_STRING_URL_EMPTY', '/^(?:' . MATCH_ALLOWED_URL_SCHEMES . ':)?[0-9a-z\s;|+[\]()=%?&_,.\-#@=\/\\\~]*$/i'); +define('MATCH_ALLOWED_PROXY_SCHEMES', '(tcp|udp|unix|udg|ssl|tls)'); +define('MATCH_PORT', '(?::[0-9]+)?'); +define('MATCH_STRING_PROXY', '/^(?:' . MATCH_ALLOWED_PROXY_SCHEMES . ':)?[0-9a-z\s;|+[\]()=%?&_,.\-#@=\/\\\~\{\}:]+' . MATCH_PORT . '$/i'); +define('MATCH_STRING_URL', '/^(?:' . MATCH_ALLOWED_URL_SCHEMES . ':)?[0-9a-z\s;|+[\]()=%?&_,.\-#@=\/\\\~\{\}:]+' . MATCH_PORT . '$/i'); +define('MATCH_STRING_URL_EMPTY', '/^(?:' . MATCH_ALLOWED_URL_SCHEMES . ':)?[0-9a-z\s;|+[\]()=%?&_,.\-#@=\/\\\~:]*' . MATCH_PORT . '$/i'); define('MATCH_GADGET_OPT', '/^[0-9a-z\s:+[\]()_.,\-&?!#@=\/\\\%]+$/i'); define('MATCH_STRING_STYLE', '/^[0-9a-z:;\-+%#(),.]*$/i'); define('MATCH_COORDS', '/^(?:(?:[0-9]+)|([a-z0-9]+(?:%[+-][0-9]+)?))$/');