jmestwa-coder commented on code in PR #686:
URL: https://github.com/apache/logging-log4cxx/pull/686#discussion_r3297047255


##########
src/main/cpp/jsonlayout.cpp:
##########
@@ -223,18 +223,21 @@ void JSONLayout::appendItem(const LogString& input, 
LogString& buf)
        {
                auto lastCodePoint = nextCodePoint;
                auto ch = Transcoder::decode(input, nextCodePoint);
+               bool escapeReplacement = false;
                if (nextCodePoint == lastCodePoint) // failed to decode input?
                {
                        nextCodePoint = input.end();
                        ch = 0xFFFD; // The Unicode replacement character
+                       escapeReplacement = true;
                }
                else if ((0xD800 <= ch && ch <= 0xDFFF) || 0x10FFFF < ch)
                {
                        ch = 0xFFFD; // The Unicode replacement character
+                       escapeReplacement = true;
                }
                else if (0x22 == ch || 0x5c == ch) // double quote or backslash?
                        ;
-               else if (0x20 <= ch) // not a control character?
+               else if (!escapeReplacement && 0x20 <= ch) // not a control 
character?

Review Comment:
   Thanks for the review and for pointing this out.
   
   I re-validated the runtime behavior against the malformed UTF-8 testcase and 
confirmed the change does not actually alter the emitted output as intended. 
The new condition is effectively a no-op in the current control flow.
   
   Given that, I’m going to withdraw this patch rather than push a speculative 
follow-up change without a demonstrated failing case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to