diff --git a/lib/public/share.php b/lib/public/share.php
index ddc9e1e066f1e2132d802013e3cf140b27ceda5b..f832d04a70f6292dc28268258983b4d2d27c9777 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -365,7 +365,7 @@ class Share {
 			return false;
 		}
 
-		// password protected shares need to me authenticated
+		// password protected shares need to be authenticated
 		if ($checkPasswordProtection && !\OCP\Share::checkPasswordProtectedShare($row)) {
 			return false;
 		}
@@ -1907,6 +1907,12 @@ class Share {
 		if (!isset($linkItem['share_with'])) {
 			return true;
 		}
+		if (!isset($linkItem['share_type'])) {
+			return true;
+		}
+		if (!isset($linkItem['id'])) {
+			return true;
+		}
 
 		if ($linkItem['share_type'] != \OCP\Share::SHARE_TYPE_LINK) {
 			return true;
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 2fe2837019fc585c898b6c4cb63168f038a4951a..d6acee6c92451de4d5a19c800750775f93affe26 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -25,6 +25,8 @@ class Test_Share extends PHPUnit_Framework_TestCase {
 	protected $userBackend;
 	protected $user1;
 	protected $user2;
+	protected $user3;
+	protected $user4;
 	protected $groupBackend;
 	protected $group1;
 	protected $group2;
@@ -656,4 +658,44 @@ class Test_Share extends PHPUnit_Framework_TestCase {
 			'Failed asserting that the share of the test.txt file by user 2 has been removed.'
 		);
 	}
+
+	/**
+	 * @dataProvider checkPasswordProtectedShareDataProvider
+	 * @param $expected
+	 * @param $item
+	 */
+	public function testCheckPasswordProtectedShare($expected, $item) {
+		\OC::$session->set('public_link_authenticated', 100);
+		$result = \OCP\Share::checkPasswordProtectedShare($item);
+		$this->assertEquals($expected, $result);
+	}
+
+	function checkPasswordProtectedShareDataProvider() {
+		return array(
+			array(true, array()),
+			array(true, array('share_with' => null)),
+			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(false, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 101)),
+			array(false, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 101)),
+		);
+
+		/*
+		if (!isset($linkItem['share_with'])) {
+			return true;
+		}
+
+		if ($linkItem['share_type'] != \OCP\Share::SHARE_TYPE_LINK) {
+			return true;
+		}
+
+		if ( \OC::$session->exists('public_link_authenticated')
+			&& \OC::$session->get('public_link_authenticated') === $linkItem['id'] ) {
+			return true;
+		}
+		 * */
+	}
 }