@@ -620,8 +620,18 @@ impl TextThreadContextHandle {
impl Display for TextThreadContext {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
- // TODO: escape title?
- writeln!(f, "<text_thread title=\"{}\">", self.title)?;
+ write!(f, "<text_thread title=\"")?;
+ for c in self.title.chars() {
+ match c {
+ '&' => write!(f, "&")?,
+ '<' => write!(f, "<")?,
+ '>' => write!(f, ">")?,
+ '"' => write!(f, """)?,
+ '\'' => write!(f, "'")?,
+ _ => write!(f, "{}", c)?,
+ }
+ }
+ writeln!(f, "\">")?;
write!(f, "{}", self.text.trim())?;
write!(f, "\n</text_thread>")
}