Skip to content

Commit

Permalink
Fix for #23066
Browse files Browse the repository at this point in the history
  • Loading branch information
TDannhauer authored and nickvergessen committed May 24, 2016
1 parent 4525427 commit 8666439
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/files_sharing/lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function authenticate($linkItem, $password = null) {
$newHash = '';
if(\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) {
// 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
Expand Down Expand Up @@ -156,7 +156,7 @@ public static function authenticate($linkItem, $password = null) {
else {
// not 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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Share/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ public static function checkPasswordProtectedShare(array $linkItem) {
}

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;
}

Expand Down
6 changes: 5 additions & 1 deletion tests/lib/Share/ShareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ public function testUnshareAll() {
* @param $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);
$this->assertEquals($expected, $result);
}
Expand All @@ -1002,8 +1002,12 @@ function checkPasswordProtectedShareDataProvider() {
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' => '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)),
);
Expand Down

0 comments on commit 8666439

Please sign in to comment.