Use only lower-case letters

Fixes https://github.com/owncloud/core/issues/11239
This commit is contained in:
Lukas Reschke 2014-09-22 21:24:33 +02:00
parent 3c5ac21122
commit 1565d82b81
2 changed files with 5 additions and 2 deletions

View File

@ -879,7 +879,7 @@ class OC_Util {
$id = OC_Config::getValue('instanceid', null); $id = OC_Config::getValue('instanceid', null);
if (is_null($id)) { if (is_null($id)) {
// We need to guarantee at least one letter in instanceid so it can be used as the session_name // We need to guarantee at least one letter in instanceid so it can be used as the session_name
$id = 'oc' . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(10); $id = 'oc' . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
OC_Config::$object->setValue('instanceid', $id); OC_Config::$object->setValue('instanceid', $id);
} }
return $id; return $id;

View File

@ -116,7 +116,10 @@ class Test_Util extends PHPUnit_Framework_TestCase {
function testGetInstanceIdGeneratesValidId() { function testGetInstanceIdGeneratesValidId() {
OC_Config::deleteKey('instanceid'); OC_Config::deleteKey('instanceid');
$this->assertStringStartsWith('oc', OC_Util::getInstanceId()); $instanceId = OC_Util::getInstanceId();
$this->assertStringStartsWith('oc', $instanceId);
$matchesRegex = preg_match('/^[a-z0-9]+$/', $instanceId);
$this->assertSame(1, $matchesRegex);
} }
/** /**