Merge pull request #24956 from owncloud/stable9-fix-shareidstring

[stable9] Backport of share id as string fix
This commit is contained in:
Vincent Petry 2016-06-02 10:11:54 +02:00
commit a780a4c966
3 changed files with 8 additions and 4 deletions

View File

@ -131,7 +131,7 @@ class Helper {
$newHash = ''; $newHash = '';
if(\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) { if(\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) {
// Save item id in session for future requests // Save item id in session for future requests
\OC::$server->getSession()->set('public_link_authenticated', $linkItem['id']); \OC::$server->getSession()->set('public_link_authenticated', (string) $linkItem['id']);
/** /**
* FIXME: Migrate old hashes to new hash format * FIXME: Migrate old hashes to new hash format
@ -161,7 +161,7 @@ class Helper {
else { else {
// not authenticated ? // not authenticated ?
if ( ! \OC::$server->getSession()->exists('public_link_authenticated') if ( ! \OC::$server->getSession()->exists('public_link_authenticated')
|| \OC::$server->getSession()->get('public_link_authenticated') !== $linkItem['id']) { || \OC::$server->getSession()->get('public_link_authenticated') !== (string)$linkItem['id']) {
return false; return false;
} }
} }

View File

@ -2477,7 +2477,7 @@ class Share extends Constants {
} }
if ( \OC::$server->getSession()->exists('public_link_authenticated') if ( \OC::$server->getSession()->exists('public_link_authenticated')
&& \OC::$server->getSession()->get('public_link_authenticated') === $linkItem['id'] ) { && \OC::$server->getSession()->get('public_link_authenticated') === (string)$linkItem['id'] ) {
return true; return true;
} }

View File

@ -1144,7 +1144,7 @@ class Test_Share extends \Test\TestCase {
* @param $item * @param $item
*/ */
public function testCheckPasswordProtectedShare($expected, $item) { public function testCheckPasswordProtectedShare($expected, $item) {
\OC::$server->getSession()->set('public_link_authenticated', 100); \OC::$server->getSession()->set('public_link_authenticated', '100');
$result = \OCP\Share::checkPasswordProtectedShare($item); $result = \OCP\Share::checkPasswordProtectedShare($item);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -1156,8 +1156,12 @@ class Test_Share extends \Test\TestCase {
array(true, array('share_with' => '')), array(true, array('share_with' => '')),
array(true, array('share_with' => '1234567890', 'share_type' => '1')), array(true, array('share_with' => '1234567890', 'share_type' => '1')),
array(true, array('share_with' => '1234567890', 'share_type' => 1)), array(true, array('share_with' => '1234567890', 'share_type' => 1)),
array(true, array('share_with' => '1234567890', 'share_type' => '3', 'id' => '100')),
array(true, array('share_with' => '1234567890', 'share_type' => 3, 'id' => '100')),
array(true, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 100)), array(true, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 100)),
array(true, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 100)), array(true, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 100)),
array(false, array('share_with' => '1234567890', 'share_type' => '3', 'id' => '101')),
array(false, array('share_with' => '1234567890', 'share_type' => 3, 'id' => '101')),
array(false, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 101)), array(false, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 101)),
array(false, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 101)), array(false, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 101)),
); );