mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-07-29 14:26:56 -04:00
fix: guard changeFilters against invalid date input in montagereview
When the datetime picker closed with an empty or malformed value, DateTime.fromFormat returned an Invalid DateTime and .valueOf() gave NaN. That NaN propagated through minTimeSecs/rangeTimeSecs into drawSliderOnGraph, where parseInt(NaN) yielded a NaN sliderX and getImageData rejected it with "Value is not of type 'long'". Return early from changeFilters when either parsed DateTime is invalid so the NaN never reaches the canvas. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1097,6 +1097,14 @@ function changeFilters(e) {
|
||||
let minStartDateTime = DateTime.fromFormat(minStartDateTimeElement.value, 'yyyy-MM-dd HH:mm:ss', {zone: ZM_TIMEZONE});
|
||||
let maxStartDateTime = DateTime.fromFormat(maxStartDateTimeElement.value, 'yyyy-MM-dd HH:mm:ss', {zone: ZM_TIMEZONE});
|
||||
|
||||
// If either input is empty or malformed, bail out rather than letting
|
||||
// NaN propagate into minTimeSecs/rangeTimeSecs and crash getImageData
|
||||
// in drawSliderOnGraph.
|
||||
if (!minStartDateTime.isValid || !maxStartDateTime.isValid) {
|
||||
console.warn("changeFilters: invalid date input, skipping update");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this === minStartDateTimeElement) {
|
||||
if (minStartDateTime > maxStartDateTime) {
|
||||
maxStartDateTime = minStartDateTime.plus({hours: 1}); // Maybe leave a gap?
|
||||
|
||||
Reference in New Issue
Block a user