mirror of
https://salsa.debian.org/mdosch/go-sendxmpp
synced 2024-11-15 00:15:10 +00:00
Replace invalid characters with UTF8 replacement char.
This commit is contained in:
parent
5d8790b222
commit
2f76178a22
@ -3,6 +3,7 @@
|
||||
## Unreleased
|
||||
### Changed
|
||||
- Properly close connection to server if ^C is pressed in interactive mode.
|
||||
- Replace invalid characters by UTF8 replacement char.
|
||||
|
||||
## [v0.6.1] 2023-07-25
|
||||
### Changed
|
||||
|
@ -19,9 +19,9 @@ import (
|
||||
|
||||
func validUTF8(s string) string {
|
||||
// Remove invalid code points.
|
||||
s = strings.ToValidUTF8(s, "")
|
||||
s = strings.ToValidUTF8(s, "<EFBFBD>")
|
||||
reg := regexp.MustCompile(`[\x{0000}-\x{0008}\x{000B}\x{000C}\x{000E}-\x{001F}]`)
|
||||
s = reg.ReplaceAllString(s, "")
|
||||
s = reg.ReplaceAllString(s, "<EFBFBD>")
|
||||
|
||||
return s
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user