diff --git a/classes/diskcache.php b/classes/diskcache.php index 9c594acc5..d7ea26d3b 100644 --- a/classes/diskcache.php +++ b/classes/diskcache.php @@ -273,7 +273,7 @@ class DiskCache { } public function get_url($filename) { - return get_self_url_prefix() . "/public.php?op=cached&file=" . basename($this->dir) . "/" . basename($filename); + return Config::get_self_url() . "/public.php?op=cached&file=" . basename($this->dir) . "/" . basename($filename); } // check for locally cached (media) URLs and rewrite to local versions diff --git a/classes/handler/public.php b/classes/handler/public.php index d26cf7a35..f7df6fc74 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -64,7 +64,7 @@ class Handler_Public extends Handler { $feed_site_url = $qfh_ret[2]; /* $last_error = $qfh_ret[3]; */ - $feed_self_url = get_self_url_prefix() . + $feed_self_url = Config::get_self_url() . "/public.php?op=rss&id=$feed&key=" . Feeds::_get_access_key($feed, false, $owner_uid); @@ -177,10 +177,8 @@ class Handler_Public extends Handler { $feed['title'] = $feed_title; $feed['feed_url'] = $feed_self_url; - - $feed['self_url'] = get_self_url_prefix(); - - $feed['articles'] = array(); + $feed['self_url'] = Config::get_self_url(); + $feed['articles'] = []; while ($line = $result->fetch()) { @@ -403,7 +401,7 @@ class Handler_Public extends Handler { if ($_REQUEST['return'] && mb_strpos($return, Config::get(Config::SELF_URL_PATH)) === 0) { header("Location: " . clean($_REQUEST['return'])); } else { - header("Location: " . get_self_url_prefix()); + header("Location: " . Config::get_self_url()); } } } @@ -780,7 +778,7 @@ class Handler_Public extends Handler { $timestamp = date("Y-m-d", strtotime($timestamp)); - return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id"; + return "tag:" . parse_url(Config::get_self_url(), PHP_URL_HOST) . ",$timestamp:/$id"; } // this should be used very carefully because this endpoint is exposed to unauthenticated users diff --git a/classes/opml.php b/classes/opml.php index 6c7cab606..aa4879c4c 100644 --- a/classes/opml.php +++ b/classes/opml.php @@ -635,7 +635,7 @@ class OPML extends Handler_Protected { } static function get_publish_url(){ - return get_self_url_prefix() . + return Config::get_self_url() . "/public.php?op=publishOpml&key=" . Feeds::_get_access_key('OPML:Publish', false, $_SESSION["uid"]); } diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 348c67bab..2708099c8 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -609,7 +609,7 @@ class PluginHost { // handled by classes/pluginhandler.php, requires valid session function get_method_url(Plugin $sender, string $method, $params = []) { - return get_self_url_prefix() . "/backend.php?" . + return Config::get_self_url() . "/backend.php?" . http_build_query( array_merge( [ @@ -622,7 +622,7 @@ class PluginHost { // shortcut syntax (disabled for now) /* function get_method_url(Plugin $sender, string $method, $params) { - return get_self_url_prefix() . "/backend.php?" . + return Config::get_self_url() . "/backend.php?" . http_build_query( array_merge( [ @@ -634,7 +634,7 @@ class PluginHost { // WARNING: endpoint in public.php, exposed to unauthenticated users function get_public_method_url(Plugin $sender, string $method, $params = []) { if ($sender->is_public_method($method)) { - return get_self_url_prefix() . "/public.php?" . + return Config::get_self_url() . "/public.php?" . http_build_query( array_merge( [ diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 24bf68c47..d6bdeab5c 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1278,7 +1278,7 @@ class Pref_Feeds extends Handler_Protected { $is_cat = clean($_REQUEST['is_cat']) == "true"; $search = clean($_REQUEST['search']); - $link = get_self_url_prefix() . "/public.php?" . http_build_query([ + $link = Config::get_self_url() . "/public.php?" . http_build_query([ 'op' => 'rss', 'id' => $feed_id, 'is_cat' => (int)$is_cat, diff --git a/classes/rpc.php b/classes/rpc.php index 0f08e78c7..4c3ecf8eb 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -175,7 +175,7 @@ class RPC extends Handler_Protected { $error_params = []; $client_scheme = parse_url($client_location, PHP_URL_SCHEME); - $server_scheme = parse_url(get_self_url_prefix(), PHP_URL_SCHEME); + $server_scheme = parse_url(Config::get_self_url(), PHP_URL_SCHEME); if (get_schema_version() != SCHEMA_VERSION) { $error = Errors::E_SCHEMA_MISMATCH; @@ -183,7 +183,7 @@ class RPC extends Handler_Protected { $error = Errors::E_URL_SCHEME_MISMATCH; $error_params["client_scheme"] = $client_scheme; $error_params["server_scheme"] = $server_scheme; - $error_params["self_url_path"] = get_self_url_prefix(); + $error_params["self_url_path"] = Config::get_self_url(); } if ($error == Errors::E_SUCCESS) { @@ -463,7 +463,7 @@ class RPC extends Handler_Protected { $max_feed_id = $row["mid"]; $num_feeds = $row["nf"]; - $params["self_url_prefix"] = get_self_url_prefix(); + $params["self_url_prefix"] = Config::get_self_url(); $params["max_feed_id"] = (int) $max_feed_id; $params["num_feeds"] = (int) $num_feeds; $params["hotkeys"] = $this->get_hotkeys_map(); diff --git a/classes/sanitizer.php b/classes/sanitizer.php index 5bb5f2efc..07766dc16 100644 --- a/classes/sanitizer.php +++ b/classes/sanitizer.php @@ -64,7 +64,9 @@ class Sanitizer { $doc->loadHTML('' . $res); $xpath = new DOMXPath($doc); - $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); + // is it a good idea to possibly rewrite urls to our own prefix? + // $rewrite_base_url = $site_url ? $site_url : Config::get_self_url(); + $rewrite_base_url = $site_url ? $site_url : "http://domain.invalid/"; $entries = $xpath->query('(//a[@href]|//img[@src]|//source[@srcset|@src])'); diff --git a/include/functions.php b/include/functions.php index 4892d5320..ce6b48181 100644 --- a/include/functions.php +++ b/include/functions.php @@ -217,7 +217,7 @@ } // this returns Config::SELF_URL_PATH sans ending slash - /** function is @deprecated */ + /** function is @deprecated by Config::get_self_url() */ function get_self_url_prefix() { return Config::get_self_url(); } diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index b90c40598..eabb33510 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -146,7 +146,7 @@ class Bookmarklets extends Plugin { if ($feed_id) { ?> -