fix: don't backslash-escape quotes inside %"..."%" summary

Remind's %"..."%" delimiter treats the content literally, so a
backslash-escaped double quote shows up as a literal backslash in the
rendered message instead of being interpreted. Only escape quotes for
non-summary MSG bodies where the delimiter isn't %"..."%".
This commit is contained in:
2026-07-14 16:28:42 +02:00
parent 89c577a125
commit e25a570004

View File

@@ -257,13 +257,13 @@ let add_through b = function
(** 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 escape_msg ?(summary = false) s =
let buf = Buffer.create (String.length s) in
String.iter
(function
| '\n' -> Buffer.add_string buf "\\n"
| '\t' -> ()
| '"' -> Buffer.add_string buf "\\\""
| '"' -> if summary then Buffer.add_string buf "\"" else Buffer.add_string buf "\\\""
| '%' -> Buffer.add_string buf "%%"
| '[' -> Buffer.add_string buf {|["["]|}
| c -> Buffer.add_char buf c)
@@ -272,7 +272,7 @@ let escape_msg s =
let add_msg b ?(alarm = empty_alarm) ?(timed = false) summary =
let has_alarm = alarm.day_delta <> "" || alarm.time_delta <> "" || alarm.sched <> "" in
let body = escape_msg summary in
let body = escape_msg summary ~summary:true in
let body =
if has_alarm then if timed then spf "%%\"%s%%\" (%%b %%3)" body else spf "%%\"%s%%\" (%%b)" body else body
in