fix: prevent AMCP channel crash on Unicode/emoji in CG UPDATE (#1106)#1707
Open
toontoet wants to merge 1 commit intoCasparCG:masterfrom
Open
fix: prevent AMCP channel crash on Unicode/emoji in CG UPDATE (#1106)#1707toontoet wants to merge 1 commit intoCasparCG:masterfrom
toontoet wants to merge 1 commit intoCasparCG:masterfrom
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
CG UPDATEwith emoji content (e.g.{"message": "Hello 😀 World"}) — connection stays aliveTest template: debug.html
Test script: emoji_utf8_test.js (use: node emoji_utf8_test.js localhost 5250)