From 2431abe91271cc9652d67121052036b01263312d Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Thu, 18 Jun 2026 17:13:26 +0200 Subject: [PATCH] fix(crash): keep event/calendar content out of exception messages Audit of our own throw sites, since exception messages land verbatim in the stack trace a crash report carries. Redacts the three that could hold user content; the rest only carry numeric ids/timestamps (metadata, kept for debugging): - create-local-calendar: drop the user-typed calendar name. - toContentValues unsupported-type: log the value's type, never the value (a cell can be an event title/description/location). - ics export open-failure: log only the Uri scheme, not the full Uri (which can embed the user's chosen filename). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../calendula/data/calendar/CalendarDataSource.kt | 6 ++++-- .../de/jeanlucmakiola/calendula/data/ics/IcsExporter.kt | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/CalendarDataSource.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/CalendarDataSource.kt index 7aa838e..ed93412 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/CalendarDataSource.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/CalendarDataSource.kt @@ -204,7 +204,8 @@ class AndroidCalendarDataSource @Inject constructor( putDescription(description) } val uri = resolver.insert(localCalendarsUri(), values) - ?: throw WriteFailedException("create local calendar '$name'") + // No calendar name in the message — it can reach a crash report. + ?: throw WriteFailedException("create local calendar") return ContentUris.parseId(uri) } @@ -685,7 +686,8 @@ class AndroidCalendarDataSource @Inject constructor( is String -> cv.put(column, value) is Long -> cv.put(column, value) is Int -> cv.put(column, value) - else -> error("Unsupported value for $column: $value") + // Only the type, never the value — a cell value can be event content. + else -> error("Unsupported value type for column '$column': ${value::class.simpleName}") } } } diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/ics/IcsExporter.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/ics/IcsExporter.kt index f593532..70b0f9a 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/ics/IcsExporter.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/ics/IcsExporter.kt @@ -24,7 +24,8 @@ class IcsExporter @Inject constructor( fun writeDocument(uri: Uri, content: String) { context.contentResolver.openOutputStream(uri)?.use { out -> out.write(content.toByteArray(Charsets.UTF_8)) - } ?: throw IOException("Could not open $uri for writing") + // Only the scheme — the full Uri can embed the user's chosen filename. + } ?: throw IOException("Could not open output stream for export (scheme=${uri.scheme})") } /**