summaryrefslogtreecommitdiff
path: root/classes/urlhelper.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-05 23:41:32 +0300
committerAndrew Dolgov <[email protected]>2021-02-05 23:41:32 +0300
commit403dca154c6b539de221f9e16174a0fdd0a1e896 (patch)
tree8187096f0e04ecb60440c8551514d990d0e85b2d /classes/urlhelper.php
parentb4cbc792cc5fbbd5356f91038bf6cf5e67a19e42 (diff)
initial WIP for php8; bump php version requirement to 7.0
Diffstat (limited to 'classes/urlhelper.php')
-rw-r--r--classes/urlhelper.php19
1 files changed, 4 insertions, 15 deletions
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index fec36de51..ecb7ed67c 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -22,7 +22,7 @@ class UrlHelper {
$rel_parts = parse_url($rel_url);
- if ($rel_parts['host'] && $rel_parts['scheme']) {
+ if (!empty($rel_parts['host']) && !empty($rel_parts['scheme'])) {
return self::validate($rel_url);
} else if (strpos($rel_url, "//") === 0) {
# protocol-relative URL (rare but they exist)
@@ -61,7 +61,7 @@ class UrlHelper {
// this isn't really necessary because filter_var(... FILTER_VALIDATE_URL) requires host and scheme
// as per https://php.watch/versions/7.3/filter-var-flag-deprecation but it might save time
- if (!$tokens['host'])
+ if (empty($tokens['host']))
return false;
if (!in_array(strtolower($tokens['scheme']), ['http', 'https']))
@@ -82,7 +82,7 @@ class UrlHelper {
// (used for validation only, we actually request the original URL, in case of urlencode breaking it)
$tokens_filter_var = $tokens;
- if ($tokens['path']) {
+ if ($tokens['path'] ?? false) {
$tokens_filter_var['path'] = implode("/",
array_map("rawurlencode",
array_map("rawurldecode",
@@ -96,7 +96,7 @@ class UrlHelper {
return false;
if ($extended_filtering) {
- if (!in_array($tokens['port'], [80, 443, '']))
+ if (!in_array($tokens['port'] ?? '', [80, 443, '']))
return false;
if (strtolower($tokens['host']) == 'localhost' || $tokens['host'] == '::1' || strpos($tokens['host'], '127.') === 0)
@@ -166,7 +166,6 @@ class UrlHelper {
global $fetch_effective_url;
global $fetch_effective_ip_addr;
global $fetch_curl_used;
- global $fetch_domain_hits;
$fetch_last_error = false;
$fetch_last_error_code = -1;
@@ -177,9 +176,6 @@ class UrlHelper {
$fetch_effective_url = "";
$fetch_effective_ip_addr = "";
- if (!is_array($fetch_domain_hits))
- $fetch_domain_hits = [];
-
if (!is_array($options)) {
// falling back on compatibility shim
@@ -235,13 +231,6 @@ class UrlHelper {
return false;
}
- $fetch_domain_hits[$url_host] += 1;
-
- /*if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) {
- user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING);
- #return false;
- }*/
-
if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) {
$fetch_curl_used = true;