mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 17:45:40 +03:00
[FacebookBridge] Handle mobile links and unify host validation (#1789)
This commit is contained in:
parent
0a1ff10a52
commit
45e2f385b3
1 changed files with 20 additions and 17 deletions
|
@ -215,16 +215,7 @@ class FacebookBridge extends BridgeAbstract {
|
|||
|
||||
$urlparts = parse_url($group);
|
||||
|
||||
if($urlparts['host'] !== parse_url(self::URI)['host']
|
||||
&& 'www.' . $urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||
|
||||
returnClientError('The host you provided is invalid! Received "'
|
||||
. $urlparts['host']
|
||||
. '", expected "'
|
||||
. parse_url(self::URI)['host']
|
||||
. '"!');
|
||||
|
||||
}
|
||||
$this->validateHost($urlparts['host']);
|
||||
|
||||
return explode('/', $urlparts['path'])[2];
|
||||
|
||||
|
@ -236,6 +227,24 @@ class FacebookBridge extends BridgeAbstract {
|
|||
|
||||
}
|
||||
|
||||
private function validateHost($provided_host) {
|
||||
// Handle mobile links
|
||||
if (strpos($provided_host, 'm.') === 0) {
|
||||
$provided_host = substr($provided_host, strlen('m.'));
|
||||
}
|
||||
|
||||
$facebook_host = parse_url(self::URI)['host'];
|
||||
|
||||
if ($provided_host !== $facebook_host
|
||||
&& 'www.' . $provided_host !== $facebook_host) {
|
||||
returnClientError('The host you provided is invalid! Received "'
|
||||
. $provided_host
|
||||
. '", expected "'
|
||||
. $facebook_host
|
||||
. '"!');
|
||||
}
|
||||
}
|
||||
|
||||
private function isPublicGroup($html) {
|
||||
|
||||
// Facebook redirects to the groups about page for non-public groups
|
||||
|
@ -348,13 +357,7 @@ class FacebookBridge extends BridgeAbstract {
|
|||
|
||||
$urlparts = parse_url($user);
|
||||
|
||||
if($urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||
returnClientError('The host you provided is invalid! Received "'
|
||||
. $urlparts['host']
|
||||
. '", expected "'
|
||||
. parse_url(self::URI)['host']
|
||||
. '"!');
|
||||
}
|
||||
$this->validateHost($urlparts['host']);
|
||||
|
||||
if(!array_key_exists('path', $urlparts)
|
||||
|| $urlparts['path'] === '/') {
|
||||
|
|
Loading…
Reference in a new issue