Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit a2aaf7192e9a93836657ae984e31fd4af986b8f7 Author: Alexander <korelskiy@uteka.ru> Date: Thu Jul 07 01:47:50 2022 +0000 Fix message html entities escaping when sending to Telegram (#1855) diff --git a/bridge/telegram/html.go b/bridge/telegram/html.go index 41326f6..4aa9fd3 100644 --- a/bridge/telegram/html.go +++ b/bridge/telegram/html.go @@ -27 +26 @@ package btelegram    import (   "bytes" - "html"     "github.com/russross/blackfriday"  ) @@ -2410 +2316 @@ func (options *customHTML) Paragraph(out *bytes.Buffer, text func() bool) {  func (options *customHTML) BlockCode(out *bytes.Buffer, text []byte, lang string) {   out.WriteString("<pre>")   - out.WriteString(html.EscapeString(string(text))) + out.WriteString(string(text))   out.WriteString("</pre>\n")  }   +func (options *customHTML) CodeSpan(out *bytes.Buffer, text []byte) { + out.WriteString("<code>") + out.WriteString(string(text)) + out.WriteString("</code>") +} +  func (options *customHTML) Header(out *bytes.Buffer, text func() bool, level int, id string) {   options.Paragraph(out, text)  } @@ -426 +4710 @@ func (options *customHTML) BlockQuote(out *bytes.Buffer, text []byte) {   out.WriteByte('\n')  }   +func (options *customHTML) LineBreak(out *bytes.Buffer) { + out.WriteByte('\n') +} +  func (options *customHTML) List(out *bytes.Buffer, text func() bool, flags int) {   options.Paragraph(out, text)  } diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 2522541..43cb818 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -1017 +1017 @@ func (b *Btelegram) Send(msg config.Message) (string, error) {   }     if b.GetString("MessageFormat") == HTMLFormat { - msg.Text = makeHTML(msg.Text) + msg.Text = makeHTML(html.EscapeString(msg.Text))   }     // Delete message