You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "swebb2066 (via GitHub)" <gi...@apache.org> on 2026/05/25 02:04:17 UTC

Re: [PR] JSONLayout escaping for malformed UTF-8 input [logging-log4cxx]

swebb2066 commented on code in PR #686:
URL: https://github.com/apache/logging-log4cxx/pull/686#discussion_r3295753892


##########
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:
   This change does nothing as `escapeReplacement` is always `false` in this conditional expression.



-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org