Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CalenTask/Support/NaturalDateParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ enum NaturalDateParser {
let cleanedText: String
}

/// #64 — oltre questa lunghezza il testo non è una frase di cattura: niente
/// regex né data detector (evita costi superlineari su input enormi).
static let maxInputLength = 500

static func parse(_ text: String, now: Date = .now, calendar: Calendar = .current) -> Match? {
guard text.count <= maxInputLength else { return nil }
if let italian = parseItalian(text, now: now, calendar: calendar) {
return italian
}
Expand Down
5 changes: 5 additions & 0 deletions CalenTaskTests/CalenTaskTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ struct DomainModelTests {
#expect(tagCount == 2) // "montaggio" survives as a workspace tag
}

@Test func naturalDateParserIgnoraTestiTroppoLunghi() {
let long = "domani " + String(repeating: "a", count: NaturalDateParser.maxInputLength)
#expect(NaturalDateParser.parse(long) == nil)
}

@Test func italianRelativeDateParsing() throws {
let calendar = Calendar.current
let now = calendar.date(from: DateComponents(year: 2026, month: 6, day: 10, hour: 10))!
Expand Down
Loading