aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-06 10:15:08 -0600
committerCraig Jennings <c@cjennings.net>2026-02-06 10:15:08 -0600
commit1ba7eedcdb83e17a900c448fd1a6de67b950d108 (patch)
treec6cea3de5395131e682661c909c87855e321961a /modules
parent01be937e4a8e014865df6f6ac3121589e80d600f (diff)
downloaddotemacs-1ba7eedcdb83e17a900c448fd1a6de67b950d108.tar.gz
dotemacs-1ba7eedcdb83e17a900c448fd1a6de67b950d108.zip
fix(calendar-sync): sanitize description text to prevent org heading corruption
Event descriptions containing lines starting with * were being interpreted as org headings, breaking file structure. Replace leading asterisks with dashes before writing descriptions.
Diffstat (limited to 'modules')
-rw-r--r--modules/calendar-sync.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/calendar-sync.el b/modules/calendar-sync.el
index c7d113a7..27fb69a1 100644
--- a/modules/calendar-sync.el
+++ b/modules/calendar-sync.el
@@ -275,6 +275,17 @@ Returns nil for nil input. Returns empty string for whitespace-only input."
(when text
(string-trim (calendar-sync--strip-html (calendar-sync--unescape-ics-text text)))))
+(defun calendar-sync--sanitize-org-body (text)
+ "Sanitize TEXT for safe inclusion as org body content.
+Replaces leading asterisks with dashes to prevent lines from being
+parsed as org headings. Handles multiple levels (e.g. ** becomes --)."
+ (when text
+ (replace-regexp-in-string
+ "^\\(\\*+\\) "
+ (lambda (match)
+ (concat (make-string (length (match-string 1 match)) ?-) " "))
+ text)))
+
;;; Date Utilities
(defun calendar-sync--add-months (date months)
@@ -1175,9 +1186,9 @@ Description appears as body text after the drawer."
(dolist (prop props)
(push prop parts))
(push ":END:" parts))
- ;; Add description as body text
+ ;; Add description as body text (sanitized to prevent org heading conflicts)
(when (and description (not (string-empty-p description)))
- (push description parts))
+ (push (calendar-sync--sanitize-org-body description) parts))
(string-join (nreverse parts) "\n"))))
(defun calendar-sync--event-start-time (event)