Skip to content

fix: disable HTML escaping in JSON encoder to preserve transaction signatures#258

Merged
ety001 merged 1 commit into
nextfrom
fix/json-html-escape
Jun 1, 2026
Merged

fix: disable HTML escaping in JSON encoder to preserve transaction signatures#258
ety001 merged 1 commit into
nextfrom
fix/json-html-escape

Conversation

@ety001

@ety001 ety001 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Problem

Go's json.Marshal escapes HTML special characters (<, >, &) to \uXXXX by default. steemd's FC JSON parser does not understand \u escapes, so a transaction body containing > (common in Markdown blockquotes) 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. Short comments without HTML special chars are unaffected.

Root Cause

  • Go's encoding/json escapes < → \u003c, > → \u003e, & → \u0026
  • steemd's FC library parseEscape() doesn't support \uXXXX Unicode escapes
  • FC parses \u003e as literal u003e (5 chars) instead of > (1 char)
  • Signature verification fails because body content was altered

Solution

  • Add helpers.MarshalJSONWithoutHTMLEscape() utility function
  • Use json.Encoder with SetEscapeHTML(false) for upstream request serialization
  • Strip trailing newline from Encoder.Encode() to match json.Marshal behavior
  • Apply to both HTTP and WebSocket upstream clients

Files Changed

  • internal/helpers/json.go - New utility function with detailed comments
  • internal/helpers/json_test.go - Unit tests (8 test cases)
  • internal/upstream/http.go - HTTP client uses utility function
  • internal/ws/client.go - WebSocket client uses utility function

Testing

  • Unit tests pass (8/8)
  • Integration tests pass
  • Dev environment deployment verified - long posts with Markdown blockquotes now work correctly

Fixes #258

…gnatures

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
@ety001 ety001 merged commit c645ee3 into next Jun 1, 2026
2 checks passed
@ety001 ety001 deleted the fix/json-html-escape branch June 1, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant