Skip to content

Fix raw HTML in Google Calendar event descriptions - #2193

Merged
callumalpass merged 2 commits into
callumalpass:mainfrom
martin-forge:martin-forge/plain-text-google-calendar-descriptions
Aug 23, 2026
Merged

Fix raw HTML in Google Calendar event descriptions#2193
callumalpass merged 2 commits into
callumalpass:mainfrom
martin-forge:martin-forge/plain-text-google-calendar-descriptions

Conversation

@martin-forge

@martin-forge martin-forge commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Problem

The Google Calendar API documents the event description field as one that can contain HTML, and Calendar's own editor stores markup there. TaskNotes consumes that string as plain text everywhere: event tooltips, the ICS event info modal, "copy as markdown", the {{icsEventDescription}} template variable, generated note bodies, and folder templates.

Several of those write the value into the vault, so raw markup was not only displayed — it was persisted into note bodies and folder names.

Fix

Normalize the description once at the Google provider boundary, parsing it with Obsidian's HTML sanitizer. Paragraph breaks, list structure, and link addresses survive the flattening.

Plain text is returned unchanged, so descriptions that merely contain angle brackets — Contact <user@example.com>, placeholders such as <TBC> — are untouched. Normalizing at the boundary keeps every consumer plain-text rather than making each one handle HTML separately. ICS subscriptions read descriptions through their own path and are unaffected.

Why not a plain textContent read

textContent drops paragraph and list breaks and discards href values, so a description holding a bulleted agenda and a meeting link collapses into one run-on line with the link gone. The flattening pass exists to keep those three things and nothing more.

Descriptions sent back to Google

Writes are unaffected. TaskCalendarSyncService rebuilds the description from the task before every update, and the drag/resize path sends only start and end. The normalized value is never round-tripped into Calendar, so formatting a user has set there is not flattened by this change.

Relationship to earlier work

This complements #1882, which fixed the TaskNotes-to-Google export; this covers the Google-to-TaskNotes input side. It is also the actual cause behind #2102, which I closed after testing: the entity handling I proposed there was a symptom of descriptions being read as plain text, not the underlying problem.

Validation

npm test -- tests/unit/utils/calendarDescription.test.ts tests/services/GoogleCalendarService.test.ts
npm run typecheck
npm run lint
npm run build

50 focused tests pass. The full suite shows no new failures against current main. Rebased on current main.

@martin-forge martin-forge changed the title Read Google Calendar descriptions as plain text Fix raw HTML in Google Calendar event descriptions Aug 3, 2026
@martin-forge
martin-forge force-pushed the martin-forge/plain-text-google-calendar-descriptions branch from accd5a1 to db11da4 Compare August 10, 2026 13:29
The Google Calendar API documents the event description field as one that can
contain HTML, and Calendar's own editor stores markup there. TaskNotes consumes
that string as plain text everywhere: event tooltips, the ICS event info modal,
copy as markdown, the {{icsEventDescription}} template variable, generated note
bodies, and folder templates. Several of those write the value into the vault,
so raw markup was persisted into notes and folder names.

Normalize the description once at the Google provider boundary, preserving
paragraph breaks, list structure, and link targets. Plain text is returned
unchanged, so angle-bracketed addresses and placeholders are untouched.
Descriptions sent back to Google are always rebuilt from the task, so this does
not round-trip flattened text into Calendar.
@martin-forge
martin-forge force-pushed the martin-forge/plain-text-google-calendar-descriptions branch from db11da4 to ef167b8 Compare August 21, 2026 21:57
# Conflicts:
#	docs/releases/unreleased.md
@callumalpass
callumalpass merged commit e611b0e into callumalpass:main Aug 23, 2026
2 checks passed
@callumalpass

Copy link
Copy Markdown
Owner

Thanks for the contribution, @martin-forge!

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