aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar rupak <nnew234567@gmail.com> 2026-01-29 14:53:08 +0545
committerGravatar GitHub <noreply@github.com> 2026-01-29 10:08:08 +0100
commitedc750fe444b6af65eccee879a048cf3e0cdd215 (patch)
treef7db9235d6b0b6fbf76bc0260a749c146f140cfa /app/Models
parent7c853cf507fa206a0157d472b53baa44240d566e (diff)
pubSub, if hub have same host it can be reached without being public (#8450)
Compares host of hub and baseUrl, to detect they can connect each other ofr pubSubHub Helps https://github.com/FreshRSS/FreshRSS/issues/8442 Changes proposed in this pull request: - if host of hub and baseUrl are same then they hub can access freshrss even in localhost How to test the feature manually: - Create pubsub server on localhost and connect to RSS instance on localhost. --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/Feed.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 511bdc54a..6a995fef0 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -1322,9 +1322,17 @@ class FreshRSS_Feed extends Minz_Model {
return false;
}
+ private static function isSameHost(string $url1, string $url2): bool {
+ $hubHost = parse_url($url1, PHP_URL_HOST);
+ $baseHost = parse_url($url2, PHP_URL_HOST);
+ return ($hubHost != null && $baseHost != null && strcasecmp($hubHost, $baseHost) === 0);
+ }
+
public function pubSubHubbubPrepare(): string|false {
$key = '';
- if (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) &&
+ $baseUrl = FreshRSS_Context::systemConf()->base_url;
+ // If they have the same host, they can reach each other (e.g., localhost to localhost)
+ if ((Minz_Request::serverIsPublic($baseUrl) || self::isSameHost($this->hubUrl, $baseUrl)) &&
$this->hubUrl !== '' && $this->selfUrl !== '' && @is_dir(PSHB_PATH)) {
$path = PSHB_PATH . '/feeds/' . sha1($this->selfUrl);
$hubFilename = $path . '/!hub.json';
@@ -1376,7 +1384,9 @@ class FreshRSS_Feed extends Minz_Model {
} else {
$url = $this->url; //Always use current URL during unsubscribe
}
- if ($url !== '' && (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) || !$state)) {
+ $baseUrl = FreshRSS_Context::systemConf()->base_url;
+ // If they have the same host, they can reach each other (e.g., localhost to localhost)
+ if ($url !== '' && (Minz_Request::serverIsPublic($baseUrl) || self::isSameHost($url, $baseUrl) || !$state)) {
$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';
$hubFile = @file_get_contents($hubFilename);
if ($hubFile === false) {