Skip to content

Commit 97d9d58

Browse files
author
Gabor Istvan Varga
committed
Added support for FIPS bugfix for python<3.9
1 parent 8a2a06c commit 97d9d58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sphinx_design/extension.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import hashlib
2+
import sys
23
from pathlib import Path
34

45
from docutils import nodes
@@ -67,7 +68,11 @@ def update_css_js(app: Sphinx):
6768
js_path.write_text(content)
6869
# Read the css content and hash it
6970
content = read_text(static_module, "style.min.css")
70-
hash = hashlib.md5(content.encode("utf8"), usedforsecurity=False).hexdigest()
71+
# Handle python >= 3.9 and specify md5 is not used for security reasons
72+
# to avoid issue with FIPS
73+
md5_has_usedforsecurity = float(sys.version[:3]) >= 3.9
74+
md5_kwargs = {"usedforsecurity": False} if md5_has_usedforsecurity else {}
75+
hash = hashlib.md5(content.encode("utf8"), **md5_kwargs).hexdigest()
7176
# Write the css file
7277
css_path = static_path / f"design-style.{hash}.min.css"
7378
app.add_css_file(css_path.name)

0 commit comments

Comments
 (0)