aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorPetr Svenda2020-02-27 14:59:40 +0100
committerPetr Svenda2020-02-27 14:59:40 +0100
commit21fe5823f70d25e57dcd8ca9d2c09081ac978e13 (patch)
tree0daa9fc11098c8b09a126e26f9f7f826f5740451 /src
parent25f2c78a0dc322f878f0802a9d08e544db3b4889 (diff)
downloadsec-certs-21fe5823f70d25e57dcd8ca9d2c09081ac978e13.tar.gz
sec-certs-21fe5823f70d25e57dcd8ca9d2c09081ac978e13.tar.zst
sec-certs-21fe5823f70d25e57dcd8ca9d2c09081ac978e13.zip
added check for presence of base url in dowload url to prevent double insertion
Diffstat (limited to 'src')
-rw-r--r--src/extract_certificates.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/extract_certificates.py b/src/extract_certificates.py
index 27bd4da3..634e21c1 100644
--- a/src/extract_certificates.py
+++ b/src/extract_certificates.py
@@ -1496,7 +1496,13 @@ def generate_download_script(file_name, certs_dir, targets_dir, base_url, downlo
for cert in download_files_certs:
# double %% is necessary to prevent replacement of %2 within script (second argument of script)
file_name_short_web = cert[0].replace(' ', '%%20')
- write_file.write('curl \"{}{}\" -o \"{}\"\n'.format(base_url, file_name_short_web, cert[1]))
+
+ if file_name_short_web.find(base_url) != -1:
+ # base url already included
+ write_file.write('curl \"{}\" -o \"{}\"\n'.format(file_name_short_web, cert[1]))
+ else:
+ # insert base url
+ write_file.write('curl \"{}{}\" -o \"{}\"\n'.format(base_url, file_name_short_web, cert[1]))
write_file.write('pdftotext \"{}\"\n\n'.format(cert[1]))
if len(download_files_certs) > 0 and len(cert) > 2:
@@ -1508,7 +1514,12 @@ def generate_download_script(file_name, certs_dir, targets_dir, base_url, downlo
for cert in download_files_certs:
# double %% is necessary to prevent replacement of %2 within script (second argument of script)
file_name_short_web = cert[2].replace(' ', '%%20')
- write_file.write('curl \"{}{}\" -o \"{}\"\n'.format(base_url, file_name_short_web, cert[3]))
+ if file_name_short_web.find(base_url) != -1:
+ # base url already included
+ write_file.write('curl \"{}\" -o \"{}\"\n'.format(file_name_short_web, cert[3]))
+ else:
+ # insert base url
+ write_file.write('curl \"{}{}\" -o \"{}\"\n'.format(base_url, file_name_short_web, cert[3]))
write_file.write('pdftotext \"{}\"\n\n'.format(cert[3]))