From a9482754eb8101b2c70c720c2dfb59ffe140af06 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Tue, 4 Sep 2018 23:17:03 +0200 Subject: [PATCH] Support whitespace and escaped slashes in /regex/ --- plugins/warnings | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/warnings b/plugins/warnings index d25f529..0cd2308 100755 --- a/plugins/warnings +++ b/plugins/warnings @@ -6,10 +6,14 @@ sub _read_warnings { open my $fh, 'revbank.warnings' or die $!; return map { - my ($matcher, $text) = split " ", $_, 2; - chomp $text; - - my ($regex) = $matcher =~ m[^/([^/]+)/$]; + my ($regex, $products, $text) = m[^ + (?: + /((?>[^/\\]++|\\.)*+)/ # /regex with support for \/escaped\/ slashes/ + | (\S+) # products IDs, comma separated + ) + \s+ + (.*) + ]x; $regex ? sub { @@ -18,7 +22,7 @@ sub _read_warnings { } : sub { my ($id, $desc) = @_; - (grep { $_ eq $id } split /,/, $matcher) ? $text : (); + (grep { $_ eq $id } split /,/, $products) ? $text : (); } } grep /\S/, grep !/^\s*#/, readline $fh; }