From 5f7a485da90506a98713954f7939015591626e67 Mon Sep 17 00:00:00 2001 From: ety001 Date: Mon, 1 Jun 2026 19:58:35 +0800 Subject: [PATCH] fix: disable HTML escaping in JSON encoder to preserve transaction signatures Go's json.Marshal escapes HTML special chars (<, >, \u0026) to \uXXXX by default. steemd's FC JSON parser does not understand \u escapes, so a transaction body containing '>' would be received as 'u003e', breaking the signature verification and causing 'Missing Posting Authority' errors. This only affects long posts/comments that contain these characters. Use json.Encoder with SetEscapeHTML(false) for both HTTP and WebSocket upstream requests. Fixes #258 --- internal/helpers/json.go | 87 +++++++++++++++++ internal/helpers/json_test.go | 175 ++++++++++++++++++++++++++++++++++ internal/upstream/http.go | 10 +- internal/ws/client.go | 5 +- 4 files changed, 274 insertions(+), 3 deletions(-) create mode 100644 internal/helpers/json.go create mode 100644 internal/helpers/json_test.go diff --git a/internal/helpers/json.go b/internal/helpers/json.go new file mode 100644 index 0000000..ccc48e0 --- /dev/null +++ b/internal/helpers/json.go @@ -0,0 +1,87 @@ +package helpers + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// MarshalJSONWithoutHTMLEscape serializes v to JSON with HTML escaping +// disabled. This function MUST be used for all upstream request serialization +// instead of json.Marshal. +// +// # Background +// +// Go's encoding/json package escapes HTML special characters by default: +// +// < → \u003c +// > → \u003e +// & → \u0026 +// +// This behavior is documented in json.Marshal: +// "String values encode as JSON strings coercing invalid UTF-8 and replacing +// HTML characters <, >, and & with \u003c, \u003e, and \u0026 so that the JSON +// will be safe to embed inside HTML