This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
The following commit(s) were added to refs/heads/trunk by this push:
new d94e716 Erroneous use of strip() can cause hasVoted to return False
on issues that have been voted on
d94e716 is described below
commit d94e7169acdc892d798e001c3f2c2d314d4c35b3
Author: Daniel Gruno <[email protected]>
AuthorDate: Mon Mar 4 12:17:57 2024 +0100
Erroneous use of strip() can cause hasVoted to return False on issues that
have been voted on
As the intent seems to be removing the .json ending from the issue ID,
let's be strict about it and instead remove the last five chars if they are
`.json`. Otherwise, issue IDs that do not conform to hexadecimals will have
their j, s, o, and n bits cut out.
---
pysteve/lib/voter.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/pysteve/lib/voter.py b/pysteve/lib/voter.py
index 43c1d70..dbc7242 100644
--- a/pysteve/lib/voter.py
+++ b/pysteve/lib/voter.py
@@ -48,7 +48,10 @@ def remove(election, basedata, UID):
def hasVoted(election, issue, uid):
- issue = issue.strip(".json")
+ # Cut away .json endings if found. This is seemingly only used with the
file-based db backend.
+ # TODO: Test if this is still needed.
+ if issue.endswith(".json"):
+ issue = issue[:-5]
return backend.voter_has_voted(election, issue, uid)
def ballots():
@@ -101,4 +104,4 @@ Powered by Apache STeVe - https://steve.apache.org
smtpObj.sendmail(sender, receivers, msg)
except SMTPException:
raise Exception("Could not send email - SMTP server down?")
-
\ No newline at end of file
+