Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit bcc2c7b

Browse files
author
the-djmaze
committed
Prevent Infinity #1540
1 parent 969dca5 commit bcc2c7b

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

dev/Common/File.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint key-spacing: 0 */
22
/* eslint quote-props: 0 */
33

4-
import { arrayLength } from 'Common/Utils';
4+
import { arrayLength, pInt } from 'Common/Utils';
55

66
export const RFC822 = 'message/rfc822';
77

@@ -274,8 +274,7 @@ export const FileInfo = {
274274
},
275275

276276
friendlySize: bytes => {
277-
bytes = parseInt(bytes, 10);
278-
bytes = isFinite(bytes) ? bytes : 0;
277+
bytes = pInt(bytes);
279278
let i = bytes ? Math.floor(Math.log(bytes) / Math.log(1024)) : 0;
280279
return (bytes / Math.pow(1024, i)).toFixed(2>i ? 0 : 1) + ' ' + sizes[i];
281280
}

dev/Common/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const
1010

1111
pInt = (value, defaultValue = 0) => {
1212
value = parseInt(value, 10);
13-
return isNaN(value) || !isFinite(value) ? defaultValue : value;
13+
return isFinite(value) ? value : defaultValue;
1414
},
1515

1616
defaultOptionsAfterRender = (domItem, item) =>

snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public function AppData(bool $bAdmin): array
583583
'MaxBlockquotesLevel' => 0,
584584
'simpleAttachmentsList' => false,
585585
'listGrouped' => $oConfig->Get('defaults', 'mail_list_grouped', false),
586-
'MessagesPerPage' => (int) $oConfig->Get('webmail', 'messages_per_page', 25),
586+
'MessagesPerPage' => \max(5, (int) $oConfig->Get('webmail', 'messages_per_page', 25)),
587587
'messageNewWindow' => false,
588588
'messageReadAuto' => true, // (bool) $oConfig->Get('webmail', 'message_read_auto', true),
589589
'MessageReadDelay' => (int) $oConfig->Get('webmail', 'message_read_delay', 5),
@@ -678,7 +678,7 @@ public function AppData(bool $bAdmin): array
678678
$aResult['simpleAttachmentsList'] = (bool)$oSettings->GetConf('simpleAttachmentsList', $aResult['simpleAttachmentsList']);
679679
$aResult['listGrouped'] = (bool)$oSettings->GetConf('listGrouped', $aResult['listGrouped']);
680680
$aResult['ContactsAutosave'] = (bool)$oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']);
681-
$aResult['MessagesPerPage'] = (int)$oSettings->GetConf('MessagesPerPage', $aResult['MessagesPerPage']);
681+
$aResult['MessagesPerPage'] = \max(5, (int)$oSettings->GetConf('MessagesPerPage', $aResult['MessagesPerPage']));
682682
$aResult['messageNewWindow'] = (int)$oSettings->GetConf('messageNewWindow', $aResult['messageNewWindow']);
683683
$aResult['messageReadAuto'] = (int)$oSettings->GetConf('messageReadAuto', $aResult['messageReadAuto']);
684684
$aResult['MessageReadDelay'] = (int)$oSettings->GetConf('MessageReadDelay', $aResult['MessageReadDelay']);

0 commit comments

Comments
 (0)