Skip to content

Commit 984933e

Browse files
committed
Only use readable chars in Share Tokens
Signed-off-by: Joas Schilling <[email protected]>
1 parent 4153e1d commit 984933e

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ public function getShares($resourceId) {
19251925
public function setPublishStatus($value, $calendar) {
19261926
$query = $this->db->getQueryBuilder();
19271927
if ($value) {
1928-
$publicUri = $this->random->generate(16, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS);
1928+
$publicUri = $this->random->generate(16, ISecureRandom::CHAR_HUMAN_READABLE);
19291929
$query->insert('dav_shares')
19301930
->values([
19311931
'principaluri' => $query->createNamedParameter($calendar->getPrincipalURI()),

apps/sharebymail/lib/ShareByMailProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,7 @@ protected function sendPasswordToOwner(IShare $share, $password) {
541541
* @return string
542542
*/
543543
protected function generateToken($size = 15) {
544-
$token = $this->secureRandom->generate(
545-
$size, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
544+
$token = $this->secureRandom->generate($size, ISecureRandom::CHAR_HUMAN_READABLE);
546545
return $token;
547546
}
548547

lib/private/Share/Share.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,7 @@ public static function shareItem($itemType, $itemSource, $shareType, $shareWith,
913913
$token = $oldToken;
914914
} else {
915915
$token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH,
916-
\OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER.
917-
\OCP\Security\ISecureRandom::CHAR_DIGITS
916+
\OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE
918917
);
919918
}
920919
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,

lib/private/Share20/Manager.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,7 @@ public function createShare(\OCP\Share\IShare $share) {
581581
$share->setToken(
582582
$this->secureRandom->generate(
583583
\OC\Share\Constants::TOKEN_LENGTH,
584-
\OCP\Security\ISecureRandom::CHAR_LOWER.
585-
\OCP\Security\ISecureRandom::CHAR_UPPER.
586-
\OCP\Security\ISecureRandom::CHAR_DIGITS
584+
\OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE
587585
)
588586
);
589587

@@ -601,9 +599,7 @@ public function createShare(\OCP\Share\IShare $share) {
601599
$share->setToken(
602600
$this->secureRandom->generate(
603601
\OC\Share\Constants::TOKEN_LENGTH,
604-
\OCP\Security\ISecureRandom::CHAR_LOWER.
605-
\OCP\Security\ISecureRandom::CHAR_UPPER.
606-
\OCP\Security\ISecureRandom::CHAR_DIGITS
602+
\OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE
607603
)
608604
);
609605
}

0 commit comments

Comments
 (0)