summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-29 07:26:07 -0700
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-29 07:26:07 -0700
commit66d7cc4c740a1f51a6871ac5129d26d62c313720 (patch)
tree61edcc39ddd89d70f5381a365aeb58342e398935
parent8ed9be540813b0793ef6376dfe2531e43a58c1bc (diff)
parent93a6ed3dab8d54fa2c735381298bec2bbcdfde41 (diff)
downloadnextcloud-server-66d7cc4c740a1f51a6871ac5129d26d62c313720.tar.gz
nextcloud-server-66d7cc4c740a1f51a6871ac5129d26d62c313720.zip
Merge pull request #2584 from mrtorrent/fix_instanceid_format
Fix instanceid format to prevent session loop
-rwxr-xr-xlib/util.php25
-rw-r--r--tests/lib/util.php5
2 files changed, 18 insertions, 12 deletions
diff --git a/lib/util.php b/lib/util.php
index 7e8fc9b6bb7..1fa3ad765d0 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -411,18 +411,19 @@ class OC_Util {
exit();
}
- /**
- * get an id unqiue for this instance
- * @return string
- */
- public static function getInstanceId() {
- $id=OC_Config::getValue('instanceid', null);
- if(is_null($id)) {
- $id=uniqid();
- OC_Config::setValue('instanceid', $id);
- }
- return $id;
- }
+ /**
+ * get an id unique for this instance
+ * @return string
+ */
+ public static function getInstanceId() {
+ $id = OC_Config::getValue('instanceid', null);
+ if(is_null($id)) {
+ // We need to guarantee at least one letter in instanceid so it can be used as the session_name
+ $id = 'oc' . uniqid();
+ OC_Config::setValue('instanceid', $id);
+ }
+ return $id;
+ }
/**
* @brief Static lifespan (in seconds) when a request token expires.
diff --git a/tests/lib/util.php b/tests/lib/util.php
index 1c9054264c9..1f253825920 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -54,4 +54,9 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$this->assertEquals('no-reply@example.com', $email);
OC_Config::deleteKey('mail_domain');
}
+
+ function testGetInstanceIdGeneratesValidId() {
+ OC_Config::deleteKey('instanceid');
+ $this->assertStringStartsWith('oc', OC_Util::getInstanceId());
+ }
}