Skip to content

Fix calendar crash when yearmatchgroup regex does not match - #4237

Closed
Antra wants to merge 1 commit into
MagicMirrorOrg:masterfrom
Antra:calendar-custom-event-fixes
Closed

Fix calendar crash when yearmatchgroup regex does not match#4237
Antra wants to merge 1 commit into
MagicMirrorOrg:masterfrom
Antra:calendar-custom-event-fixes

Conversation

@Antra

@Antra Antra commented Aug 29, 2026

Copy link
Copy Markdown

Description

Fixes an issue in CalendarUtils.titleTransform() when a title transformation uses yearmatchgroup but the configured regular expression does not match the event title.

Currently, matchAll() returns an empty array when there is no match, but the code subsequently accesses yearmatch[0].length. This results in an exception and causes the calendar module to stop displaying its events.

This can occur when using yearmatchgroup for birthday events, for example, when some matching events have a birth year in the expected format while another event matching the keyword does not.

Change

Check that yearmatch contains at least one match before accessing yearmatch[0].

This is a one-line change and leaves the existing behaviour unchanged when the regular expression matches.

Example

With a transformation such as:

transform: {
    search: "^(.+) \\((\\d{4})\\)$",
    replace: "$1 ($2)",
    yearmatchgroup: 2
}

an event such as:

Test Birthday (1987)

continues to be transformed to:

Test Birthday (39)

while an event matching the custom-event keyword but not the year pattern no longer causes the calendar module to fail.

@Antra Antra changed the title Fix calendar crash when yearmtchgroup regex does not match Fix calendar crash when yearmatchgroup regex does not match Aug 29, 2026
@KristjanESPERANTO

Copy link
Copy Markdown
Collaborator

@Antra Thanks, but please base your pull requests against the develop branch.

@Antra Antra closed this Aug 29, 2026
@Antra

Antra commented Aug 29, 2026

Copy link
Copy Markdown
Author

Resubmitted as:
#4239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants