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

[PR] preserve UTF-16 surrogate pairs in MaskXmlInvalidCharacters - fixes #290 (logging-log4net)

FreeAndNil opened a new pull request, #291:
URL: https://github.com/apache/logging-log4net/pull/291

   fixes #290
   
   The regex [^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD] operated on individual UTF-16 char units, causing both halves of a valid surrogate pair to be replaced, silently corrupting supplementary characters (U+10000–U+10FFFF) such as emoji in XML log output.
   
   Fix by prepending a surrogate-pair alternative to the regex so valid pairs are matched and preserved as a unit; only lone surrogates and other XML-illegal code units are replaced with the mask string.
   
   Also optimise CountSubstrings: use a char loop for single-character substrings (all current callers) and StringComparison.Ordinal for the multi-character CDATA token path.
   
   Add unit tests covering surrogate pair preservation, lone surrogates, and CountSubstrings edge cases.


-- 
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


Re: [PR] preserve UTF-16 surrogate pairs in MaskXmlInvalidCharacters - fixes #290 (logging-log4net)

Posted by "FreeAndNil (via GitHub)" <gi...@apache.org>.
FreeAndNil merged PR #291:
URL: https://github.com/apache/logging-log4net/pull/291


-- 
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