@@ -91,17 +91,20 @@ public function getRemoteCollaboraURL($remote) {
9191 return '' ;
9292 }
9393
94- public function isTrustedRemote ($ domainWithPort ) {
95- if (str_starts_with ($ domainWithPort , 'http:// ' ) || str_starts_with ($ domainWithPort , 'https:// ' )) {
96- $ port = parse_url ($ domainWithPort , PHP_URL_PORT );
97- $ domainWithPort = parse_url ($ domainWithPort , PHP_URL_HOST ) . ($ port ? ': ' . $ port : '' );
94+ public function isTrustedRemote ($ domain ) {
95+ if (str_starts_with ($ domain , 'http:// ' ) || str_starts_with ($ domain , 'https:// ' )) {
96+ $ parsedDomain = parse_url ($ domain );
97+
98+ $ fullDomain = $ parsedDomain ['host ' ];
99+ $ fullDomain = $ fullDomain . ($ parsedDomain ['port ' ] ? ': ' . $ parsedDomain ['port ' ] : '' );
100+ $ fullDomain = $ fullDomain . ($ parsedDomain ['path ' ] ?: '' );
98101 }
99102
100- if ($ this ->appConfig ->isTrustedDomainAllowedForFederation () && $ this ->trustedServers !== null && $ this ->trustedServers ->isTrustedServer ($ domainWithPort )) {
103+ if ($ this ->appConfig ->isTrustedDomainAllowedForFederation () && $ this ->trustedServers !== null && $ this ->trustedServers ->isTrustedServer ($ fullDomain )) {
101104 return true ;
102105 }
103106
104- $ domain = $ this ->getDomainWithoutPort ($ domainWithPort );
107+ $ domain = $ this ->getDomainWithoutPort ($ fullDomain );
105108
106109 $ trustedList = array_merge ($ this ->appConfig ->getGlobalScaleTrustedHosts (), [$ this ->request ->getServerHost ()]);
107110 if (!is_array ($ trustedList )) {
@@ -113,7 +116,7 @@ public function isTrustedRemote($domainWithPort) {
113116 break ;
114117 }
115118 $ regex = '/^ ' . implode ('[-\.a-zA-Z0-9]* ' , array_map (fn ($ v ) => preg_quote ($ v , '/ ' ), explode ('* ' , $ trusted ))) . '$/i ' ;
116- if (preg_match ($ regex , $ domain ) || preg_match ($ regex , $ domainWithPort )) {
119+ if (preg_match ($ regex , $ domain ) || preg_match ($ regex , $ fullDomain )) {
117120 return true ;
118121 }
119122 }
0 commit comments