Sanitize strings by default on all platforms.

Instead of sanitizing strings only on iOS, we do it on all platforms.
This commit is contained in:
M. Thiercelin 2022-11-03 12:26:48 +01:00
parent 04803505f8
commit 4971d78a53
No known key found for this signature in database
GPG key ID: 29581E7E24EBEC0A
4 changed files with 11 additions and 16 deletions

View file

@ -5,6 +5,7 @@ import (
"encoding/base64"
"errors"
"io"
"io/ioutil"
"testing"
"time"
@ -83,7 +84,12 @@ func TestTextMixedMessageDecryptionWithPassword(t *testing.T) {
t.Fatal("Expected no error when decrypting, got:", err)
}
assert.Exactly(t, readTestFile("message_mixedPasswordPublicExpected", true), decrypted.GetString())
expected, err := ioutil.ReadFile("testdata/message_mixedPasswordPublicExpected")
if err != nil {
panic(err)
}
assert.Exactly(t, expected, decrypted.GetBinary())
}
func TestTextMessageEncryption(t *testing.T) {

View file

@ -1,8 +1,7 @@
//go:build !ios
// +build !ios
package crypto
import "strings"
func sanitizeString(input string) string {
return input
return strings.ToValidUTF8(input, "\ufffd")
}

View file

@ -1,10 +0,0 @@
//go:build ios
// +build ios
package crypto
import "strings"
func sanitizeString(input string) string {
return strings.ToValidUTF8(input, "\ufffd")
}