diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-11 14:55:27 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-11 14:55:27 +0100 |
commit | a8922e9d359e1be1ecd724474e31bb589e3c0067 (patch) | |
tree | c9933b0583da362b554f1f4900130e96dc446c41 | |
parent | a7f6f10d4e29521f9650e569455ba85dbb8e2654 (diff) | |
parent | dc6789fd5bf4ef537a543fcafc90070265a8ee7c (diff) | |
download | nextcloud-server-a8922e9d359e1be1ecd724474e31bb589e3c0067.tar.gz nextcloud-server-a8922e9d359e1be1ecd724474e31bb589e3c0067.zip |
Merge pull request #23125 from owncloud/add-port-support-to-trusteddomain
Explicitly check for port
-rw-r--r-- | lib/private/security/trusteddomainhelper.php | 6 | ||||
-rw-r--r-- | tests/lib/security/trusteddomainhelper.php | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/private/security/trusteddomainhelper.php b/lib/private/security/trusteddomainhelper.php index 885ceee23c3..409628677a7 100644 --- a/lib/private/security/trusteddomainhelper.php +++ b/lib/private/security/trusteddomainhelper.php @@ -78,6 +78,12 @@ class TrustedDomainHelper { if (preg_match(Request::REGEX_LOCALHOST, $domain) === 1) { return true; } + + // Compare with port appended + if(in_array($domainWithPort, $trustedList, true)) { + return true; + } + return in_array($domain, $trustedList, true); } diff --git a/tests/lib/security/trusteddomainhelper.php b/tests/lib/security/trusteddomainhelper.php index 52a8f1be630..3581211ce61 100644 --- a/tests/lib/security/trusteddomainhelper.php +++ b/tests/lib/security/trusteddomainhelper.php @@ -42,7 +42,12 @@ class TrustedDomainHelperTest extends \Test\TestCase { * @return array */ public function trustedDomainDataProvider() { - $trustedHostTestList = ['host.one.test', 'host.two.test', '[1fff:0:a88:85a3::ac1f]']; + $trustedHostTestList = [ + 'host.one.test', + 'host.two.test', + '[1fff:0:a88:85a3::ac1f]', + 'host.three.test:443', + ]; return [ // empty defaults to false with 8.1 [null, 'host.one.test:8080', false], @@ -56,6 +61,9 @@ class TrustedDomainHelperTest extends \Test\TestCase { [$trustedHostTestList, '[1fff:0:a88:85a3::ac1f]', true], [$trustedHostTestList, '[1fff:0:a88:85a3::ac1f]:801', true], [$trustedHostTestList, '[1fff:0:a88:85a3::ac1f]:801:34', false], + [$trustedHostTestList, 'host.three.test:443', true], + [$trustedHostTestList, 'host.three.test:80', false], + [$trustedHostTestList, 'host.three.test', false], // trust localhost regardless of trust list [$trustedHostTestList, 'localhost', true], [$trustedHostTestList, 'localhost:8080', true], |