From a7ea02d5923c106e8a1e597d399262ed615a1704 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Tue, 29 Mar 2022 22:56:47 +0200 Subject: [PATCH] Non-greedy matching for votestrings. A single choice on a ballot has this format: #1 [ ] This or that The regexp in uvvote.pl's process_vote() will match and extract what's beetwen "[" and "]". But if "This or that" contains a "]", the match will be too greedy: #1 [ ] This [or that] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- match Fix that by using a non-greedy operator. Signed-off-by: Thomas Hochstein --- uvvote.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uvvote.pl b/uvvote.pl index c101f1f..a151250 100755 --- a/uvvote.pl +++ b/uvvote.pl @@ -271,7 +271,7 @@ sub process_vote { } # this matches on a single appearance: - if ($$body =~ /#$votenum\W*?\[(.+)\]/) { + if ($$body =~ /#$votenum\W*?\[(.+?)\]/) { # one or more vote strings were found $onevote ||= 1; # set $onevote to 1 if it was 0 my $votestring = $1;