fix(cron): reject out-of-range cli relative times · openclaw/openclaw@660a6de
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -248,6 +248,13 @@ describe("parseAt", () => {
|
248 | 248 | it("rejects out-of-range epoch milliseconds", () => { |
249 | 249 | expect(parseAt(String(Number.MAX_SAFE_INTEGER))).toBeNull(); |
250 | 250 | }); |
| 251 | + |
| 252 | +it("rejects relative durations outside the Date range", () => { |
| 253 | +vi.useFakeTimers(); |
| 254 | +vi.setSystemTime(new Date("2026-05-25T00:00:00.000Z")); |
| 255 | + |
| 256 | +expect(parseAt("+999999999999999999d")).toBeNull(); |
| 257 | +}); |
251 | 258 | }); |
252 | 259 | |
253 | 260 | describe("getCronChannelOptions", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,7 @@ import {
|
10 | 10 | parseOffsetlessIsoDateTimeInTimeZone, |
11 | 11 | } from "../../infra/format-time/parse-offsetless-zoned-datetime.js"; |
12 | 12 | import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; |
| 13 | +import { timestampMsToIsoString } from "../../shared/number-coercion.js"; |
13 | 14 | import { |
14 | 15 | normalizeLowercaseStringOrEmpty, |
15 | 16 | normalizeOptionalString, |
@@ -198,12 +199,12 @@ export function parseAt(input: string, tz?: string): string | null {
|
198 | 199 | |
199 | 200 | const absolute = parseAbsoluteTimeMs(raw); |
200 | 201 | if (absolute !== null) { |
201 | | -return new Date(absolute).toISOString(); |
| 202 | +return timestampMsToIsoString(absolute) ?? null; |
202 | 203 | } |
203 | 204 | const durationInput = raw.startsWith("+") ? raw.slice(1) : raw; |
204 | 205 | const dur = parseDurationMs(durationInput); |
205 | 206 | if (dur !== null) { |
206 | | -return new Date(Date.now() + dur).toISOString(); |
| 207 | +return timestampMsToIsoString(Date.now() + dur) ?? null; |
207 | 208 | } |
208 | 209 | return null; |
209 | 210 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。