Skip to content

Comments

fix: prevent AMCP channel crash on Unicode/emoji in CG UPDATE (#1106)#1707

Open
toontoet wants to merge 1 commit intoCasparCG:masterfrom
toontoet:fix/utf8-cg-update
Open

fix: prevent AMCP channel crash on Unicode/emoji in CG UPDATE (#1106)#1707
toontoet wants to merge 1 commit intoCasparCG:masterfrom
toontoet:fix/utf8-cg-update

Conversation

@toontoet
Copy link
Contributor

boost::log throws conversion_error when logging wide strings containing characters outside the system locale's encoding (e.g. emojis on C locale). Since this exception is unhandled in the AMCP protocol handler, it kills the connection when running CasparCG in Docker.

Fix by sanitizing log output with replace_nonprintable() in the three places where user-supplied wide strings are logged:

  • AMCPProtocolStrategy: received AMCP messages
  • html_producer: CEF console messages and renderer process messages
  • strategy_adapters: sent response messages

Also replace boost::wformat with string concatenation in html_cg_proxy::update() to avoid a secondary crash path, and use explicit skip method for UTF-8 conversion to gracefully handle any invalid sequences.

This is a minimal rework of the earlier #1673 PR, addressing the review feedback to reduce code changes.

Test plan

  • Send CG UPDATE with emoji content (e.g. {"message": "Hello 😀 World"}) — connection stays alive
  • Send complex multi-byte emojis (flags 🇳🇱, families 👨‍👩‍👧‍👦, skin tones 👋🏻) — no crash
  • Send mixed ASCII + Unicode + emoji content — works correctly
  • Verify emojis render correctly in the HTML template
  • Verify AMCP connection remains stable after multiple emoji updates

Test template: debug.html
Test script: emoji_utf8_test.js (use: node emoji_utf8_test.js localhost 5250)

…CG#1106)

boost::log throws conversion_error when logging wide strings containing
characters outside the system locale's encoding (e.g. emojis on C locale).
Since this exception is unhandled in the AMCP protocol handler, it kills
the connection.

Fix by sanitizing log output with replace_nonprintable() in the three
places where user-supplied wide strings are logged:
- AMCPProtocolStrategy: received AMCP messages
- html_producer: CEF console messages and renderer process messages
- strategy_adapters: sent response messages

Also replace boost::wformat with string concatenation in
html_cg_proxy::update() to avoid a secondary crash path, and use
explicit skip method for UTF-8 conversion to gracefully handle any
invalid sequences.

Co-authored-by: Cursor <cursoragent@cursor.com>
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