Relax parsing of RFC3164 syslog message format
authorJacob Bachmeyer <jcb@gnu.org>
Thu, 4 Mar 2021 02:40:08 +0000 (20:40 -0600)
committerJacob Bachmeyer <jcb@gnu.org>
Thu, 4 Mar 2021 02:40:08 +0000 (20:40 -0600)
testsuite/lib/exec/minlogd.pl

index e018f2997efefff6a07d50af30b7e02595538993..4d600957a50d346abc9389e7456226cd725a43f8 100755 (executable)
@@ -140,8 +140,8 @@ sub handle_message ($) {
     if (m/^(<[[:digit:]]+>)/g) { $PRI = $1 }
     else { $PRI = '<13>' }
 
-    if (m/\G(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s
-         (\d{2})\s(\d{2}):(\d{2}):(\d{2})\s/gcx)
+    if (m/\G(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
+         (\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+/gcx)
       { $TIMESTAMP =
          strftime '%Y-%m-%dT%H:%M:%S',
            $5, $4, $3, $2, $Months{$1}-1, (localtime)[5..8] }
@@ -149,7 +149,7 @@ sub handle_message ($) {
       { $TIMESTAMP =
          strftime '%Y-%m-%dT%H:%M:%S', localtime }
 
-    if (m/\G([-[:alnum:]]+) /gc) { $HOSTNAME = $1 }
+    if (m/\G([-[:alnum:]]+) +/gc) { $HOSTNAME = $1 }
     else { $HOSTNAME = 'localhost' }
 
     $MSG = substr $_, pos $_ if pos $_;