From a4d0698628c39e5b2ba06ae3344441e75abb1a5e Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 19 Apr 2022 17:42:26 +0200 Subject: [PATCH] Fix parsing of smartcardoptions config With the previous code, a trailing newline would result in an empty space being part of the list. When this is passed to keytool, it fails with "Illegal option: ". Instead of doing overly complicated regex based string substitution followed by parametrized splitting, we can simply use `.split()` without any parameters, and Python will automatically strip any whitespace. --- fdroidserver/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index b18887c7..7d1b6715 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -385,7 +385,8 @@ def read_config(opts=None): # smartcardoptions must be a list since its command line args for Popen smartcardoptions = config.get('smartcardoptions') if isinstance(smartcardoptions, str): - config['smartcardoptions'] = re.sub(r'\s+', r' ', config['smartcardoptions']).split(' ') + options = re.sub(r'\s+', r' ', config['smartcardoptions']).split(' ') + config['smartcardoptions'] = [i.strip() for i in options if i] elif not smartcardoptions and 'keystore' in config and config['keystore'] == 'NONE': # keystore='NONE' means use smartcard, these are required defaults config['smartcardoptions'] = ['-storetype', 'PKCS11', '-providerName',