From b9f5201405ce5145f258c7e909397f4cf1f3bd23 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Mon, 9 Jan 2012 02:39:57 +0100 Subject: [PATCH 1/5] Check correct voting in ballot. It's possible that ballots get mixed up when a voter is participating in more than one voting and sending the ballots manually (by copying and pasting them into his mail client). UseVote could - and should! - check that the ballot belongs to the current voting by comparing the ballot introduction ("WAHLSCHEIN fuer ...") with the votename and throw an error if they don't match. * Add ballotintro (default: WAHLSCHEIN fuer) and tpl_wrong_voting (default: wrong-voting) to usevote.cfg * Add messages to messages.cfg * Modify ballot and ballot-personal templates accordingly * Add check to uvvote.pl * Add error handling to UVmenu.pm * Change UVmenu::menu call in uvcfv.pl due to new parameter ($voting) Signed-off-by: Thomas Hochstein --- UVmenu.pm | 22 ++++++++++++++++++++-- messages.cfg | 6 ++++++ templates/ballot | 2 +- templates/ballot-personal | 2 +- usevote.cfg | 5 +++++ usevote.global.cfg | 5 +++++ uvcfv.pl | 4 ++-- uvvote.pl | 17 ++++++++++++++++- 8 files changed, 56 insertions(+), 7 deletions(-) diff --git a/UVmenu.pm b/UVmenu.pm index d90da9c..cd523e8 100644 --- a/UVmenu.pm +++ b/UVmenu.pm @@ -17,7 +17,8 @@ $VERSION = "0.4"; ############################################################################## # Menu for interaction with the votetaker # # Parameters: votes list and header (references to arrays) # -# Body, Mailadress, Name, Ballot ID (references to strings) # +# Body, Mailadress, Name, Ballot ID, # +# Voting (references to strings) # # List of newly set fields (reference to array) # # List of errors to correct (Array-Ref) # # Return Values: 'w': proceed # @@ -25,7 +26,7 @@ $VERSION = "0.4"; ############################################################################## sub menu { - my ($votes, $header, $body, $addr, $name, $ballot_id, $set, $errors) = @_; + my ($votes, $header, $body, $addr, $name, $ballot_id, $voting, $set, $errors) = @_; my $input = ""; my $voter_addr = $$addr || ''; my $voter_name = $$name || ''; @@ -79,6 +80,7 @@ sub menu { print "(5) ", UVmessage::get("MENU_BALLOT_ID"), " [$$ballot_id]\n" if ($config{personal}); print "(6) ", UVmessage::get("MENU_BDSG"), "\n" if ($config{bdsg}); + print "(7) ", UVmessage::get("MENU_VOTING"), " [", $$voting, "]\n"; } print "\n", @@ -269,6 +271,22 @@ sub menu { $errors{InvalidBDSG} = UVmessage::get("MENU_INVALIDBDSG"); } + } elsif ($input eq '7') { + my $sel; + do { + print "[a] ", UVmessage::get("MENU_VOTING_CORRECT"), "\n", + "[b] ", UVmessage::get("MENU_VOTING_WRONG"), "\n\n", + UVmessage::get("MENU_PROMPT"); + $sel = ; + } until ($sel =~ /^[ab]$/i); + + if ($sel =~ /^a$/i) { + delete $errors{NoVoting}; + delete $errors{WrongVoting}; + } else { + $errors{WrongVoting} = UVmessage::get("MENU_WRONGVOTING"); + } + } elsif ($input =~ /^i$/i) { my $ignore = UVmessage::get("MENU_IGNORE_STRING"); # Set columns for Text::Wrap diff --git a/messages.cfg b/messages.cfg index 8dca33c..6c9b339 100644 --- a/messages.cfg +++ b/messages.cfg @@ -29,6 +29,8 @@ MENU_INVALIDBDSG = Datenschutzhinweis fehlerhaft oder nicht bestaetigt. MENU_DUPLICATEVOTE = Doppelte Stimmabgabe gefunden. MENU_NOVOTE = Keine Stimmabgabe gefunden. MENU_INVALIDVOTE = Ungueltige Stimmabgabe. +MENU_NOVOTING = Bezeichnung der Abstimmung nicht gefunden. +MENU_WRONGVOTING = Wahlschein fuer andere Abstimmung. MENU_NOBALLOTID = Keine Scheinkennung gefunden. MENU_WRONGBALLOTID = Scheinkennung falsch. MENU_ADDRESSNOTREGISTERED = Adresse nicht registriert. @@ -67,6 +69,9 @@ MENU_BALLOT_ID = Scheinkennung MENU_BDSG = Datenschutzklausel MENU_BDSG_ACCEPTED = Datenschutzklausel wurde akzeptiert MENU_BDSG_DECLINED = Datenschutzklausel nicht akzeptiert bzw. Text veraendert +MENU_VOTING = Abstimmung +MENU_VOTING_CORRECT = Korrekter Wahlschein fuer diese Abstimmung +MENU_VOTING_WRONG = Wahlschein fuer andere Abstimmung MENU_IGNORE = Diese Stimme ignorieren (ohne Benachrichtigung verwerfen) MENU_IGNORE_WARNING = Die Stimme wird nicht aufgezeichnet, und es wird keine Bestaetigung verschickt. ${MENU_IGNORE_STRING} eingeben, wenn Du sicher bist: MENU_IGNORE_STRING = JA @@ -173,6 +178,7 @@ VOTE_UNREGISTERED_ADDRESS = Adresse nicht registriert VOTE_INVALID_VOTE = Ungueltige Stimmabgabe VOTE_VIOLATED_RULE = Regel ${RULE} verletzt VOTE_NO_VOTES = Keine Stimmen abgegeben +VOTE_WRONG_VOTING = Wahlschein gehoert nicht zu dieser Abstimmung VOTE_INVALID_ACCOUNT = Ungueltiger Account VOTE_INVALID_ADDRESS = Ungueltige Adresse VOTE_INVALID_REALNAME = Ungueltiger Realname diff --git a/templates/ballot b/templates/ballot index 5e3242a..30add33 100644 --- a/templates/ballot +++ b/templates/ballot @@ -14,7 +14,7 @@ bdsgtext-more := value bdsgtext | drop-words 50 | create-lines 50 =-=-=-=-=-=-=-=- Alles vor dieser Zeile bitte loeschen =-=-=-=-=-=-=-=- -WAHLSCHEIN fuer [$votename-first] +[$ballotintro] [$votename-first] [@votename-more| [$line]\n] diff --git a/templates/ballot-personal b/templates/ballot-personal index 13aef2a..495baec 100644 --- a/templates/ballot-personal +++ b/templates/ballot-personal @@ -29,7 +29,7 @@ votetaker := value mailfrom | fill-left 65 =-=-=-=-=-=-=-=- Alles vor dieser Zeile bitte loeschen =-=-=-=-=-=-=-=- -WAHLSCHEIN fuer [$votename-first] +[$ballotintro] [$votename-first] [@votename-more| [$line]\n] diff --git a/usevote.cfg b/usevote.cfg index cf801f5..ed464fa 100644 --- a/usevote.cfg +++ b/usevote.cfg @@ -227,6 +227,10 @@ mailstart = "^From " begin_divider = Alles vor dieser Zeile bitte loeschen end_divider = Alles nach dieser Zeile bitte loeschen +# Ueberschrift fuer den Wahlschein +# Achtung, muss im Wahlschein genauso stehen! +ballotintro = WAHLSCHEIN fuer + # Text fuer die Namens-Angabe im Wahlschein. Achtung, muss im # Wahlschein genauso stehen! nametext = Dein Realname, falls nicht im FROM-Header: @@ -290,4 +294,5 @@ tpl_invalid_name = "invalid-name" # used by uvvote.pl tpl_multiple_votes = "multiple-votes" # used by uvvote.pl tpl_no_ballot = "no-ballot" # used by uvvote.pl tpl_no_votes = "no-votes" # used by uvvote.pl +tpl_wrong_voting = "wrong-voting" # used by uvvote.pl tpl_rule_violated = "rule-violated" # used by uvvote.pl (c.f. usevote.rul) diff --git a/usevote.global.cfg b/usevote.global.cfg index beb859f..2ba69b4 100644 --- a/usevote.global.cfg +++ b/usevote.global.cfg @@ -99,6 +99,10 @@ mailstart = "^From " begin_divider = Alles vor dieser Zeile bitte loeschen end_divider = Alles nach dieser Zeile bitte loeschen +# Ueberschrift fuer den Wahlschein +# Achtung, muss im Wahlschein genauso stehen! +ballotintro = WAHLSCHEIN fuer + # Text fuer die Namens-Angabe im Wahlschein. Achtung, muss im # Wahlschein genauso stehen! nametext = Dein Realname, falls nicht im FROM-Header: @@ -162,4 +166,5 @@ tpl_invalid_name = "invalid-name" # used by uvvote.pl tpl_multiple_votes = "multiple-votes" # used by uvvote.pl tpl_no_ballot = "no-ballot" # used by uvvote.pl tpl_no_votes = "no-votes" # used by uvvote.pl +tpl_wrong_voting = "wrong-voting" # used by uvvote.pl tpl_rule_violated = "rule-violated" # used by uvvote.pl (c.f. usevote.rul) diff --git a/uvcfv.pl b/uvcfv.pl index 74174c6..6179915 100755 --- a/uvcfv.pl +++ b/uvcfv.pl @@ -152,9 +152,9 @@ sub process_request { # check for suspicious addresses foreach my $element (@bad_addr) { if ($voter_addr =~ /^$element/) { - my (@votes, @set, $ballot_id); # irrelevant, but necessary for UVmenu::menu() + my (@votes, @set, $ballot_id, $voting); # irrelevant, but necessary for UVmenu::menu() my @errors = ('SuspiciousAccountBallot'); - my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name, \$ballot_id, \@set, \@errors); + my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name, \$ballot_id, \$voting, \@set, \@errors); # "Ignore": don't deliver a ballot return 0 if ($res eq 'i'); diff --git a/uvvote.pl b/uvvote.pl index c859504..836903a 100755 --- a/uvvote.pl +++ b/uvvote.pl @@ -224,6 +224,7 @@ sub process_vote { my $onevote = 0; # 0=no votes, 1=everything OK, 2=vote cancelled my $voteerror = ""; # error message in case of invalid vote my $ballot_id = ""; # ballot id (German: Wahlscheinkennung) + my $voting = ""; # voting (should be votename) # found address? if ($voter_addr) { @@ -239,6 +240,14 @@ sub process_vote { push (@errors, 'InvalidAddress'); } + # correct voting? + if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*$/m) { + $voting = $1; + push (@errors, 'WrongVoting') if ($config{votename} !~ /^\s*\Q$voting\E\s*$/); + } else { + push (@errors, 'NoVoting'); + } + # personalized ballots? if ($config{personal}) { if ($$body =~ /$config{ballotidtext}\s+([a-z0-9]+)/) { @@ -343,7 +352,7 @@ sub process_vote { # Errors encountered? if (@errors) { my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name, - \$ballot_id, \@set, \@errors); + \$ballot_id, \$voting, \@set, \@errors); return 0 if ($res eq 'i'); # "Ignore": Ignore vote, don't save my $tpl; @@ -402,6 +411,12 @@ sub process_vote { my $msg = $template->processTemplate($config{tpl_bdsg_error}); UVsendmail::mail($voter_addr, "Fehler", $msg, $msgid) if ($config{voteack}); return 0; + } elsif ($error{NoVoting} or $error{WrongVoting}) { + $voteerror = UVmessage::get("VOTE_WRONG_VOTING"); + my $template = UVtemplate->new(); + $template->setKey('body' => $$body); + my $msg = $template->processTemplate($config{tpl_wrong_voting}); + UVsendmail::mail($voter_addr, "Fehler", $msg, $msgid) if ($config{voteack}); } elsif ($error{NoVote}) { $voteerror = UVmessage::get("VOTE_NO_VOTES"); my $template = UVtemplate->new(); From f908d8a11a6556f28409e60863215c8daf444e60 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Wed, 11 Jan 2012 11:03:20 +0100 Subject: [PATCH 2/5] Fix regular expression. Support votenames longer than one line (in fact, support votenames up to two lines long). Signed-off-by: Thomas Hochstein --- uvvote.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uvvote.pl b/uvvote.pl index 836903a..67754d2 100755 --- a/uvvote.pl +++ b/uvvote.pl @@ -241,8 +241,9 @@ sub process_vote { } # correct voting? - if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*$/m) { + if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*\n(.*?[\t ]+(\S+.+)\s*$)?/m) { $voting = $1; + $voting .= " $3" if defined($3); push (@errors, 'WrongVoting') if ($config{votename} !~ /^\s*\Q$voting\E\s*$/); } else { push (@errors, 'NoVoting'); From 1ca99f7368300731796307f6e4d971ee6dbb2da7 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 21 Jan 2012 09:49:14 +0100 Subject: [PATCH 3/5] Add forgotten template. Signed-off-by: Thomas Hochstein --- templates/wrong-voting | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 templates/wrong-voting diff --git a/templates/wrong-voting b/templates/wrong-voting new file mode 100644 index 0000000..1d12e31 --- /dev/null +++ b/templates/wrong-voting @@ -0,0 +1,21 @@ +votetaker := value mailfrom | fill-left 65 +body := value body | quote "> " + +== TEMPLATE ================================================================= +Offenbar hast du einen Wahlschein fuer eine andere Abstimmung eingesandt +oder der Name der Abstimmung geht aus dem Wahlschein nicht hervor. Wenn +das ein Irrtum war, pruefe bitte noch einmal die im CfV angegebene +Abstimmungsadresse und wiederhole Deine Stimmabgabe. + +Dieser Fehler kann auftreten, wenn Du an mehreren Abstimmungen teilnimmst +und den Wahlschein von Hand einsendest (und dabei mehrere Abstimmungen +verwechselst), oder wenn Du die Bezeichnung der Abstimmung im Wahlschein +veraendert oder geloescht hast. + +Hier die Mail, die ich erhalten habe: + +[$body] + + +[$votetaker] +\[mit [$usevote_version]\] \ No newline at end of file From a374bef4c7e8de63bc43471d5a3d2795173a1070 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sun, 22 Jan 2012 13:46:33 +0100 Subject: [PATCH 4/5] Correctly find $votename. If the ballot is not quoted, the current regular expression will match $nametext (minus its first word) as second line of $votename. Change regular expression to match only certain common quote characters at beginning of second line. (Perhaps it would be even better to stop matching on empty lines ...) Check for erroneus match on $nametext as a safety measure. Signed-off-by: Thomas Hochstein --- uvvote.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uvvote.pl b/uvvote.pl index 67754d2..9505edc 100755 --- a/uvvote.pl +++ b/uvvote.pl @@ -241,9 +241,9 @@ sub process_vote { } # correct voting? - if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*\n(.*?[\t ]+(\S+.+)\s*$)?/m) { + if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*\n([>:|]*?[\t ]+(\S+.+)\s*$)?/m) { $voting = $1; - $voting .= " $3" if defined($3); + $voting .= " $3" if (defined($3) and $3 !~ /\Q$config{nametext}\E/); push (@errors, 'WrongVoting') if ($config{votename} !~ /^\s*\Q$voting\E\s*$/); } else { push (@errors, 'NoVoting'); From 95135a11026182b0e8ce31f91703d66c3c444f23 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 15 Feb 2014 17:07:48 +0100 Subject: [PATCH 5/5] Display current voting identifier in menu. Add a header line with the identifier (name) of the currently processed voting to the menu display by UVmenu so one can check whether the ballot really belongs to the current voting even when checking more than one voting in a batch. Signed-off-by: Thomas Hochstein --- UVmenu.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/UVmenu.pm b/UVmenu.pm index cd523e8..5d96c8e 100644 --- a/UVmenu.pm +++ b/UVmenu.pm @@ -60,6 +60,7 @@ sub menu { while (1) { system($config{clearcmd}); + print "-> $config{votename} <-\n"; print UVmessage::get("MENU_PROBLEMS") . "\n"; foreach my $error (keys %errors) {