feat(remind): escape special characters in MSG clause body
This commit is contained in:
@@ -121,7 +121,20 @@ let add_through b = function
|
|||||||
| Some d -> Buffer.add_string b (spf " THROUGH %s" (Timedesc.Date.to_rfc3339 d))
|
| Some d -> Buffer.add_string b (spf " THROUGH %s" (Timedesc.Date.to_rfc3339 d))
|
||||||
| None -> ()
|
| 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 =
|
let date_of_date_or_datetime (d : Icalendar.date_or_datetime) : Timedesc.Date.t =
|
||||||
match d with
|
match d with
|
||||||
|
|||||||
Reference in New Issue
Block a user