Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-11-13 13:15:47 +0300
committerLukas Reschke <lukas@owncloud.com>2014-11-13 13:15:47 +0300
commit786007c78cb8f585284a749df3164c1de6447d83 (patch)
treee5e4b3456989d3d5c723df9d8d4460ba3690c0ec /lib/private/request.php
parentf52662ab26664ac9bf29ac557089884913fa5cbf (diff)
Ignore port for trusted domains
This lead to a lot of confusion in the past and did not really offer any value. Let's remove the port check therefore. (it's anyways not really a part of the domain) Fixes https://github.com/owncloud/core/issues/12150 and https://github.com/owncloud/core/issues/12123 and also a problem reported by @DeepDiver1975.
Diffstat (limited to 'lib/private/request.php')
-rw-r--r--lib/private/request.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/private/request.php b/lib/private/request.php
index 221a21a258f..b9b23776088 100644
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -13,7 +13,7 @@ class OC_Request {
const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#';
const USER_AGENT_FREEBOX = '#^Mozilla/5\.0$#';
- const REGEX_LOCALHOST = '/^(127\.0\.0\.1|localhost)(:[0-9]+|)$/';
+ const REGEX_LOCALHOST = '/^(127\.0\.0\.1|localhost)$/';
/**
* Check overwrite condition
@@ -36,13 +36,26 @@ class OC_Request {
* have been configured
*/
public static function isTrustedDomain($domain) {
- $trustedList = \OC_Config::getValue('trusted_domains', array());
+ // Extract port from domain if needed
+ $pos = strrpos($domain, ':');
+ if ($pos !== false) {
+ $port = substr($domain, $pos + 1);
+ if (is_numeric($port)) {
+ $domain = substr($domain, 0, $pos);
+ }
+ }
+
+ // FIXME: Empty config array defaults to true for now. - Deprecate this behaviour with ownCloud 8.
+ $trustedList = \OC::$server->getConfig()->getSystemValue('trusted_domains', array());
if (empty($trustedList)) {
return true;
}
+
+ // Always allow access from localhost
if (preg_match(self::REGEX_LOCALHOST, $domain) === 1) {
return true;
}
+
return in_array($domain, $trustedList);
}