From ba8c943fcd93d8c822671596e2631ca92fcb3ca3 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Oct 27 2022 22:33:43 +0000 Subject: Improve filtering of comma-separated bug strings Thanks to @nielsenb for pointing out an issue here in #22. I decided on a slightly different fix though. Signed-off-by: Adam Williamson --- diff --git a/relval/report_results.py b/relval/report_results.py index d704521..2fa0550 100644 --- a/relval/report_results.py +++ b/relval/report_results.py @@ -117,14 +117,16 @@ def get_result(username): bugs = input("Enter the IDs of any bugs associated with this report, " "separated by commas. ") - if bugs == '': - bugs = None - else: - white = re.compile(r'\s') - bugs = white.sub('', bugs) + if bugs: + # filter all whitespace + bugs = re.sub(r'\s', '', bugs) + # split on commas bugs = bugs.split(',') - if bugs == '': - bugs = None + # drop any empty strings + bugs = [bug for bug in bugs if bug] + if not bugs: + # turn '' or [] into None + bugs = None comment = '' comm = input("Enter a comment if you like. If not, just hit Enter.\n" "Maximum length is 250 characters.\nPlease don't leave a "