Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Include host port in validateUrl for CURLOPT_RESOLVE, reported by @Kairos-T

givanz987859983589
diff --git a/system/functions.php b/system/functions.php
index 387774f..9225338 100755
--- a/system/functions.php
+++ b/system/functions.php
@@ -1778,16 +1778,23 @@ function download($url) {
}
function validateUrl($url) {
- $p = parse_url($url);
- if (! $p || ! in_array($p['scheme'] ?? '', ['http', 'https'], true) || empty($p['host'])) {
- return '';
+ $p = parse_url($url);
+ $scheme = $p['scheme'] ?? 'https';
+ $port = $p['port'] ?? ($scheme === 'http' ? '80' : '443');
+
+ if (! $p || ! in_array($scheme, ['http', 'https'], true) || ! in_array($port, ['80', '443'], true) || empty($p['host'])) {
+ return [];
+ }
+
+ if (($scheme === 'http' && $port !== '80') || ($scheme === 'https' && $port !== '443')) {
+ return [];
}
- $ips = gethostbynamel($p['host']) ?: [];
+ $ips = gethostbynamel($p['host']) ?: [];
$results = [];
foreach ($ips as $ip) {
- $results[] = $p['host'] . ':443:[' . $ip .']';
+ $results[] = $p['host'] . ':' . $port . ':[' . $ip . ']';
if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
return []; // private / reserved / loopback / link-local