feat(remind): escape special characters in MSG clause body

This commit is contained in:
2026-05-17 13:25:19 +02:00
parent 3fc322934d
commit 63d0e197ad

View File

@@ -121,7 +121,20 @@ let add_through b = function
| Some d -> Buffer.add_string b (spf " THROUGH %s" (Timedesc.Date.to_rfc3339 d))
| None -> ()
let add_msg b summary = Buffer.add_string b (spf " MSG %s\n" summary)
(** Escape special characters in the body of a MSG clause.
- '%' must become '%%' (literal percent)
- '[' must become '["["]' (a Remind expression that evaluates to the literal string "[") *)
let escape_msg s =
let buf = Buffer.create (String.length s) in
String.iter
(function
| '%' -> Buffer.add_string buf "%%"
| '[' -> Buffer.add_string buf {|["["]|}
| c -> Buffer.add_char buf c)
s;
Buffer.contents buf
let add_msg b summary = Buffer.add_string b (spf " MSG %s\n" (escape_msg summary))
let date_of_date_or_datetime (d : Icalendar.date_or_datetime) : Timedesc.Date.t =
match d with