From 0dad6284780e265549d2b69f06c17be794a2d9de Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Fri, 28 Apr 2023 14:34:35 +0200 Subject: process-cve-records: improve description parsing --- bin/process-cve-records | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/process-cve-records b/bin/process-cve-records index 7cf9d2605c..a5d074655d 100755 --- a/bin/process-cve-records +++ b/bin/process-cve-records @@ -67,10 +67,19 @@ def parse_record(record, cve): if desc['lang'].startswith('en')] if desc: desc = desc[0] - if desc and len(desc) > 70: + # for some reason descriptions may contain new lines desc = desc.replace('\n', ' ') - desc = desc[:70] + ' ...' + + # and even non-printable characters such as \xa0 ( ) + desc = "".join([ c for c in desc if c.isprintable() ]) + + # and some contain leading spaces + desc = desc.strip() + + if len(desc) > 70: + desc = desc[:70] + ' ...' + cve.header.description = f"({desc})" if not is_reserved(record) and not is_rejected(record) \ -- cgit v1.2.3