|
20 | 20 | using System; |
21 | 21 | using System.Runtime.InteropServices; |
22 | 22 |
|
| 23 | +using log4net.Appender.Internal; |
23 | 24 | using log4net.Core; |
24 | 25 | using log4net.Util; |
25 | 26 |
|
@@ -353,7 +354,7 @@ public override void ActivateOptions() |
353 | 354 | protected override void Append(LoggingEvent loggingEvent) |
354 | 355 | { |
355 | 356 | int priority = GeneratePriority(Facility, GetSeverity(loggingEvent.EnsureNotNull().Level)); |
356 | | - string message = EscapeNulCharacters(RenderLoggingEvent(loggingEvent)); |
| 357 | + string message = NativeStringEscape.EscapeNulCharacters(RenderLoggingEvent(loggingEvent)); |
357 | 358 |
|
358 | 359 | // The second argument is a printf style format string. |
359 | 360 | if (NewLineHandling == SyslogNewLineHandling.Split) |
@@ -405,26 +406,6 @@ private static string[] SplitLines(string message) |
405 | 406 |
|
406 | 407 | private static readonly string[] _newLines = ["\r\n", "\n", "\r"]; |
407 | 408 |
|
408 | | - /// <summary> |
409 | | - /// Replaces NUL characters with a visible <c>\0</c> escape. |
410 | | - /// </summary> |
411 | | - /// <param name="message">The rendered message.</param> |
412 | | - /// <returns>The message with every NUL character escaped.</returns> |
413 | | - /// <remarks> |
414 | | - /// <para> |
415 | | - /// The message is marshaled to libc as a null-terminated string, so a NUL character anywhere in |
416 | | - /// it would end the record there and silently drop everything the layout rendered after it, |
417 | | - /// including trailing fields and exception text. Logged content is not trusted and may well |
418 | | - /// contain a NUL, so the character is escaped rather than passed through. |
419 | | - /// </para> |
420 | | - /// <para> |
421 | | - /// Newlines are handled separately, see <see cref="NewLineHandling"/>. Other control characters |
422 | | - /// are passed through. |
423 | | - /// </para> |
424 | | - /// </remarks> |
425 | | - private static string EscapeNulCharacters(string message) |
426 | | - => message.IndexOf('\0') < 0 ? message : message.Replace("\0", "\\0"); |
427 | | - |
428 | 409 | /// <summary> |
429 | 410 | /// Close the syslog when the appender is closed |
430 | 411 | /// </summary> |
|
0 commit comments