Skip to content

Commit

Permalink
Prevent Infinity #1540
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Apr 8, 2024
1 parent 969dca5 commit bcc2c7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions dev/Common/File.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint key-spacing: 0 */
/* eslint quote-props: 0 */

import { arrayLength } from 'Common/Utils';
import { arrayLength, pInt } from 'Common/Utils';

export const RFC822 = 'message/rfc822';

Expand Down Expand Up @@ -274,8 +274,7 @@ export const FileInfo = {
},

friendlySize: bytes => {
bytes = parseInt(bytes, 10);
bytes = isFinite(bytes) ? bytes : 0;
bytes = pInt(bytes);
let i = bytes ? Math.floor(Math.log(bytes) / Math.log(1024)) : 0;
return (bytes / Math.pow(1024, i)).toFixed(2>i ? 0 : 1) + ' ' + sizes[i];
}
Expand Down
2 changes: 1 addition & 1 deletion dev/Common/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const

pInt = (value, defaultValue = 0) => {
value = parseInt(value, 10);
return isNaN(value) || !isFinite(value) ? defaultValue : value;
return isFinite(value) ? value : defaultValue;
},

defaultOptionsAfterRender = (domItem, item) =>
Expand Down
4 changes: 2 additions & 2 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public function AppData(bool $bAdmin): array
'MaxBlockquotesLevel' => 0,
'simpleAttachmentsList' => false,
'listGrouped' => $oConfig->Get('defaults', 'mail_list_grouped', false),
'MessagesPerPage' => (int) $oConfig->Get('webmail', 'messages_per_page', 25),
'MessagesPerPage' => \max(5, (int) $oConfig->Get('webmail', 'messages_per_page', 25)),
'messageNewWindow' => false,
'messageReadAuto' => true, // (bool) $oConfig->Get('webmail', 'message_read_auto', true),
'MessageReadDelay' => (int) $oConfig->Get('webmail', 'message_read_delay', 5),
Expand Down Expand Up @@ -678,7 +678,7 @@ public function AppData(bool $bAdmin): array
$aResult['simpleAttachmentsList'] = (bool)$oSettings->GetConf('simpleAttachmentsList', $aResult['simpleAttachmentsList']);
$aResult['listGrouped'] = (bool)$oSettings->GetConf('listGrouped', $aResult['listGrouped']);
$aResult['ContactsAutosave'] = (bool)$oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']);
$aResult['MessagesPerPage'] = (int)$oSettings->GetConf('MessagesPerPage', $aResult['MessagesPerPage']);
$aResult['MessagesPerPage'] = \max(5, (int)$oSettings->GetConf('MessagesPerPage', $aResult['MessagesPerPage']));
$aResult['messageNewWindow'] = (int)$oSettings->GetConf('messageNewWindow', $aResult['messageNewWindow']);
$aResult['messageReadAuto'] = (int)$oSettings->GetConf('messageReadAuto', $aResult['messageReadAuto']);
$aResult['MessageReadDelay'] = (int)$oSettings->GetConf('MessageReadDelay', $aResult['MessageReadDelay']);
Expand Down

0 comments on commit bcc2c7b

Please sign in to comment.