BugFix: Unverifiable Events with Unicode 2028 and 2029 characters.

This commit is contained in:
Vitor Pamplona
2023-03-04 17:03:43 -05:00
parent 58e0aa5f8f
commit 42dd900491
2 changed files with 32 additions and 0 deletions
@@ -41,7 +41,15 @@ open class Event(
tags,
content
)
// GSON decided to hardcode these replacements.
// They break Nostr's hash check.
// These lines revert their code.
// https://github.com/google/gson/issues/2295
val rawEventJson = gson.toJson(rawEvent)
.replace("\\u2028", "\u2028")
.replace("\\u2029", "\u2029")
return sha256.digest(rawEventJson.toByteArray()).toHexKey()
}