Skip to content

Fix date extension crash on invalid format (#993) - #2516

Merged
AucaCoyan merged 6 commits into
espanso:devfrom
gcailly:fix-issue-993-date-format-crash
Oct 11, 2025
Merged

AucaCoyan merged 6 commits into
espanso:devfrom
gcailly:fix-issue-993-date-format-crash

Conversation

@gcailly

@gcailly gcailly commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

Invalid date format specifiers (e.g., %Y-%m-%dT%H:%i:%s%Q) caused the daemon to panic.

Changes :

  • Add DateExtensionError enum with InvalidFormat variant
  • Use write!() to catch formatting errors instead of calling .to_string() directly
  • Return ExtensionResult::Error instead of panicking
  • Add regression test with the problematic format from the issue

Fixes #993

…panso#2483)

When running commands like `espanso service --help` or `espanso package --help`,
the CLI was displaying the main application help instead of the specific
subcommand help.

This was caused by using `clap_instance.print_help()` which always prints
the root command help, instead of using `err.exit()` which properly handles
contextual help for subcommands.

Fix: Use `err.exit()` to let Clap handle contextual help display.

Fixes espanso#2483
Replace markdown 0.3.0 with pulldown-cmark 0.13.0 to fix excessive <p> tags
in nested lists. The old markdown library was adding paragraph tags inside
list items when they contained sublists, which caused extra spacing in rich
text editors and email clients.

pulldown-cmark is CommonMark-compliant and correctly handles tight lists
(no blank lines between items) by not adding <p> tags inside <li> elements.

This also eliminates the need for catch_unwind protection since pulldown-cmark
doesn't panic on malformed markdown, unlike the old library (see espanso#759).

Fixes espanso#2217
Invalid date format specifiers caused the daemon to panic and crash.
Now returns a proper error instead.

- Add DateExtensionError with InvalidFormat variant
- Use write!() to catch formatting errors
- Add regression test
@gcailly
gcailly requested a review from AucaCoyan as a code owner October 6, 2025 16:33
@AucaCoyan

Copy link
Copy Markdown
Collaborator

Just reverted the mardown part that is for a separate PR 👍🏼

@AucaCoyan

Copy link
Copy Markdown
Collaborator

Thank you! this fixes perfectly! 🚀

@AucaCoyan
AucaCoyan merged commit 83b1f04 into espanso:dev Oct 11, 2025
gcailly added a commit to gcailly/espanso that referenced this pull request Oct 11, 2025
Allow users to format dates in different timezones using the optional
'tz' parameter. Supports IANA timezone names (e.g., UTC, America/New_York,
Europe/Paris) and falls back to local time for invalid timezones.

- Add chrono-tz dependency for timezone support
- Implement timezone conversion in date extension
- Add error handling for invalid date formats (compatible with espanso#2516)
- Add tests for UTC, named timezones, and invalid timezone fallback
gcailly added a commit to gcailly/espanso that referenced this pull request Oct 11, 2025
Allow users to format dates in different timezones using the optional
'tz' parameter. Supports IANA timezone names (e.g., UTC, America/New_York,
Europe/Paris) and falls back to local time for invalid timezones.

- Add chrono-tz dependency for timezone support
- Implement timezone conversion in date extension
- Add error handling for invalid date formats (compatible with espanso#2516)
- Add tests for UTC, named timezones, and invalid timezone fallback
gcailly added a commit to gcailly/espanso that referenced this pull request Oct 11, 2025
Allow users to format dates in different timezones using the optional
'tz' parameter. Supports IANA timezone names (e.g., UTC, America/New_York,
Europe/Paris) and falls back to local time for invalid timezones.

- Add chrono-tz dependency for timezone support
- Implement timezone conversion in date extension
- Add error handling for invalid date formats (compatible with espanso#2516)
- Add tests for UTC, named timezones, and invalid timezone fallback
AucaCoyan added a commit that referenced this pull request Oct 11, 2025
* Add timezone support to date extension (#2225)

Allow users to format dates in different timezones using the optional
'tz' parameter. Supports IANA timezone names (e.g., UTC, America/New_York,
Europe/Paris) and falls back to local time for invalid timezones.

- Add chrono-tz dependency for timezone support
- Implement timezone conversion in date extension
- Add error handling for invalid date formats (compatible with #2516)
- Add tests for UTC, named timezones, and invalid timezone fallback

* Add tz parameter to date extension JSON schema (#2225)

* move deps into the workspace

* add enum of timezones

---------

Co-authored-by: Auca Maillot <[email protected]>
sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
* Fix date extension crash on invalid format (espanso#993)

Invalid date format specifiers caused the daemon to panic and crash.
Now returns a proper error instead.

- Add DateExtensionError with InvalidFormat variant
- Use write!() to catch formatting errors
- Add regression test
sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
* Add timezone support to date extension (espanso#2225)

Allow users to format dates in different timezones using the optional
'tz' parameter. Supports IANA timezone names (e.g., UTC, America/New_York,
Europe/Paris) and falls back to local time for invalid timezones.

- Add chrono-tz dependency for timezone support
- Implement timezone conversion in date extension
- Add error handling for invalid date formats (compatible with espanso#2516)
- Add tests for UTC, named timezones, and invalid timezone fallback

* Add tz parameter to date extension JSON schema (espanso#2225)

* move deps into the workspace

* add enum of timezones

---------
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.

Date format doesn't exist, don't crash

2 participants