Sanitize non utf8 strings before returning them to iOS apps
In swift, strings must be strictly utf8, and when golang returns a string with non utf8 characters, it gets translated to an empty string for utf8. To avoid this situation, we sanitize strings before returning them. This behavior is only enabled when building with the "ios" build tag.
This commit is contained in:
parent
6021e54d03
commit
a2fd1c6a3b
4 changed files with 21 additions and 2 deletions
|
|
@ -202,7 +202,7 @@ func (msg *PlainMessage) GetBinary() []byte {
|
|||
|
||||
// GetString returns the content of the message as a string.
|
||||
func (msg *PlainMessage) GetString() string {
|
||||
return strings.ReplaceAll(string(msg.Data), "\r\n", "\n")
|
||||
return sanitizeString(strings.ReplaceAll(string(msg.Data), "\r\n", "\n"))
|
||||
}
|
||||
|
||||
// GetBase64 returns the base-64 encoded binary content of the message as a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue