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 <thh@inter.net>
This commit is contained in:
parent
fb9d3eb071
commit
b9f5201405
22
UVmenu.pm
22
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 = <STDIN>;
|
||||
} 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
4
uvcfv.pl
4
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');
|
||||
|
|
17
uvvote.pl
17
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();
|
||||
|
|
Loading…
Reference in a new issue