Skip to content

Commit

Permalink
formatting: When escaping HTML, also remove invalid characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Dec 9, 2023
1 parent eb4b608 commit d62d613
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ var htmlTelegramEscaper = strings.NewReplacer(
`"`, """,
)

// Some characters lead to an "unsupported characters" message
var invalidCharacterRemover = strings.NewReplacer(
"\u0020", "",
)

func Escape(s string) string {
return htmlTelegramEscaper.Replace(s)
text := htmlTelegramEscaper.Replace(s)
return invalidCharacterRemover.Replace(text)
}

func RoundAndFormatThousand(n float64) string {
Expand Down

0 comments on commit d62d613

Please sign in to comment.