mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Cap delay strings to 100 years
This is to avoid issues with max date values and other similar edge cases. This was an issue when accidentally passing a user ID as the time value for e.g. reminders.
This commit is contained in:
parent
eee1c6d789
commit
dbcd5e7de2
1 changed files with 8 additions and 0 deletions
|
@ -296,6 +296,10 @@ export const tDelayString = new t.Type<string, string>(
|
||||||
s => s,
|
s => s,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// To avoid running into issues with the JS max date vaLue, we cap maximum delay strings *far* below that.
|
||||||
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#The_ECMAScript_epoch_and_timestamps
|
||||||
|
const MAX_DELAY_STRING_AMOUNT = 100 * 365 * DAYS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a "delay string" such as "1h30m" to milliseconds
|
* Turns a "delay string" such as "1h30m" to milliseconds
|
||||||
*/
|
*/
|
||||||
|
@ -317,6 +321,10 @@ export function convertDelayStringToMS(str, defaultUnit = "m"): number {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ms > MAX_DELAY_STRING_AMOUNT) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue