You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2021/06/05 10:09:27 UTC
svn commit: r1890492 - /httpd/site/trunk/content/security/cvejsontohtml.py
Author: jailletc36
Date: Sat Jun 5 10:09:27 2021
New Revision: 1890492
URL: http://svn.apache.org/viewvc?rev=1890492&view=rev
Log:
Improve natural order sorting
Modified:
httpd/site/trunk/content/security/cvejsontohtml.py
Modified: httpd/site/trunk/content/security/cvejsontohtml.py
URL: http://svn.apache.org/viewvc/httpd/site/trunk/content/security/cvejsontohtml.py?rev=1890492&r1=1890491&r2=1890492&view=diff
==============================================================================
--- httpd/site/trunk/content/security/cvejsontohtml.py (original)
+++ httpd/site/trunk/content/security/cvejsontohtml.py Sat Jun 5 10:09:27 2021
@@ -10,6 +10,11 @@ parser.add_option("-e","--extratext",hel
parser.add_option("-i","--inputdirectory",help="directory of json files",dest="directory")
(options,args) = parser.parse_args()
+
+def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
+ return [int(text) if text.isdigit() else text.lower()
+ for text in _nsre.split(s)]
+
filterversion = options.filterversion or ""
cves = []
entries = {}
@@ -66,8 +71,8 @@ for k,v in sorted(entries.items(), key=l
else:
# Otherwise maybe we started doing things like "<2.7.8"
affects.append(ver["version_affected"]+ver["version_value"])
- # Make a natural order sort (i.e. revrite version like 0002.4.8 and 002.4.38)
- affects.sort(reverse=True, key=lambda x: '{0:0>8}'.format(x).lower())
+ # Make a natural order sort
+ affects.sort(reverse=True, key=natural_sort_key)
e['affects'] = ", ".join(affects)
e['timetable'] = [];
for time in cve["timeline"]: