mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
Validate slash command time minutes
* fix: reject hour > 23 in 'today/tomorrow' reminder time parsing * fix: reject minute > 59 in reminder time parsing
This commit is contained in:
@@ -1464,6 +1464,7 @@ function _parseTimeSpec(input) {
|
|||||||
const mer = (m[4] || '').toLowerCase();
|
const mer = (m[4] || '').toLowerCase();
|
||||||
if (mer === 'pm' && hh < 12) hh += 12;
|
if (mer === 'pm' && hh < 12) hh += 12;
|
||||||
if (mer === 'am' && hh === 12) hh = 0;
|
if (mer === 'am' && hh === 12) hh = 0;
|
||||||
|
if (hh > 23 || mm > 59) return null;
|
||||||
d.setHours(hh, mm, 0, 0);
|
d.setHours(hh, mm, 0, 0);
|
||||||
return { date: d, rest: m[5].trim() };
|
return { date: d, rest: m[5].trim() };
|
||||||
}
|
}
|
||||||
@@ -1477,9 +1478,9 @@ function _parseTimeSpec(input) {
|
|||||||
const mer = (m[3] || '').toLowerCase();
|
const mer = (m[3] || '').toLowerCase();
|
||||||
if (mer === 'pm' && hh < 12) hh += 12;
|
if (mer === 'pm' && hh < 12) hh += 12;
|
||||||
if (mer === 'am' && hh === 12) hh = 0;
|
if (mer === 'am' && hh === 12) hh = 0;
|
||||||
// Require an hour <= 23 and either a minute field or am/pm to avoid
|
// Require a valid hour/minute and either a minute field or am/pm to
|
||||||
// eating plain numbers like "3 apples".
|
// avoid eating plain numbers like "3 apples".
|
||||||
if (hh > 23) return null;
|
if (hh > 23 || mm > 59) return null;
|
||||||
if (m[2] == null && !mer) return null;
|
if (m[2] == null && !mer) return null;
|
||||||
d.setHours(hh, mm, 0, 0);
|
d.setHours(hh, mm, 0, 0);
|
||||||
if (d.getTime() <= now.getTime()) d.setDate(d.getDate() + 1);
|
if (d.getTime() <= now.getTime()) d.setDate(d.getDate() + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user