summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-12-03 19:54:48 +0100
committerLukas Reschke <lukas@owncloud.com>2014-12-03 19:59:50 +0100
commit69f5f6649e05dd404aa67fab95c5bb34e9ce4d1f (patch)
treee32a952022705582e372ed4fb246172e120404f2 /lib
parent8700ffe69809d7551a08f224537650b43add2a59 (diff)
downloadnextcloud-server-69f5f6649e05dd404aa67fab95c5bb34e9ce4d1f.tar.gz
nextcloud-server-69f5f6649e05dd404aa67fab95c5bb34e9ce4d1f.zip
Trim port from domain
Depending on the used environment the port might be appended to the host header resulting in an inaccessible instance when initially setting up on a system with a different HTTP or HTTPS port. (for example test:500) To test this setup ownCloud under a different port with and without this patch. (heads-up: localhost is always white-listed, so use a different domain)
Diffstat (limited to 'lib')
-rw-r--r--lib/private/request.php24
-rw-r--r--lib/private/setup.php2
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/private/request.php b/lib/private/request.php
index d079dc110d1..794b566ce58 100644
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -66,6 +66,22 @@ class OC_Request {
}
/**
+ * Strips a potential port from a domain (in format domain:port)
+ * @param $host
+ * @return string $host without appended port
+ */
+ public static function getDomainWithoutPort($host) {
+ $pos = strrpos($host, ':');
+ if ($pos !== false) {
+ $port = substr($host, $pos + 1);
+ if (is_numeric($port)) {
+ $host = substr($host, 0, $pos);
+ }
+ }
+ return $host;
+ }
+
+ /**
* Checks whether a domain is considered as trusted from the list
* of trusted domains. If no trusted domains have been configured, returns
* true.
@@ -76,13 +92,7 @@ class OC_Request {
*/
public static function isTrustedDomain($domain) {
// 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);
- }
- }
+ $domain = self::getDomainWithoutPort($domain);
// FIXME: Empty config array defaults to true for now. - Deprecate this behaviour with ownCloud 8.
$trustedList = \OC::$server->getConfig()->getSystemValue('trusted_domains', array());
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 1443de18546..e5eb2bac194 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -162,7 +162,7 @@ class OC_Setup {
&& is_array($options['trusted_domains'])) {
$trustedDomains = $options['trusted_domains'];
} else {
- $trustedDomains = array(OC_Request::serverHost());
+ $trustedDomains = array(\OC_Request::getDomainWithoutPort(\OC_Request::serverHost()));
}
if (OC_Util::runningOnWindows()) {