From 506ad7de0dfc6f2343bbc2d43a403e2b8c6e05ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Kopp?= Date: Wed, 10 Nov 2021 20:38:41 +0100 Subject: [PATCH] escape \ character (#34) --- scripts/log2sql.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/log2sql.pl b/scripts/log2sql.pl index dffe705..be91ab2 100755 --- a/scripts/log2sql.pl +++ b/scripts/log2sql.pl @@ -84,8 +84,10 @@ while(my $line = ){ $lines_read++; $line =~ s/\n$//; + my $escapedline = $line; + $escapedline =~ s/\\/\\\\/g; my ($remote_addr, $remote_user, $time_local, $method, $request, $protocol, $status, $body_bytes_sent,$http_referer, $http_user_agent, $unit) = - $line =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) - ([^\s]+) \[(\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} \+\d{4})\] +"([A-Z]+) ([^" ]*) ([^" ]*)" (2\d\d) ([-\d]*) "([^"]*)" "([^"]*)" [^\s]* [^\s]* [^\s](?: .*billing:infclen=(\d+))?/; + $escapedline =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) - ([^\s]+) \[(\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} \+\d{4})\] +"([A-Z]+) ([^" ]*) ([^" ]*)" (2\d\d) ([-\d]*) "([^"]*)" "([^"]*)" [^\s]* [^\s]* [^\s](?: .*billing:infclen=(\d+))?/; $unit //=0; if($status && $request !~ /$ignore/){ $last_read_line_checksum = Digest::MD5::md5_hex($line);