Skip to content

Prevent invalid month strings from hanging the gap timeline loop #619

Closed

Description

@realmarcin

Found during adversarial review of #618.

GapSearch.prepare() in assets/gaps/search-core.js accepts any ^\d{4}-\d{2} date prefix (including out-of-range months such as 00 or 13–99), while nextMonth(ym) only rolls the year over when m === 12 and summarizeAnalytics() loops with lexicographic cur <= last. If items carry e.g. 2026-13-01 and 2027-01-01, spanMonths is 0 (<= 60) and nextMonth increments '2026-14', ..., '2026-100', ... forever ('2026-...' <= '2027-01'), hanging the Web Worker.

Fix:

  • Restrict posedMonth, resolvedMonth, and matchesMonth to valid calendar months (01–12).
  • Drive month gap-filling with bounded integer month arithmetic rather than string cur <= last.
  • Add unit tests covering invalid month strings, year rollover, empty-month interpolation, and >60-month spans.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions