Skip to content

Commit 1d6ea60

Browse files
ephesc00kiemon5ter
authored andcommitted
Remove import of deprecated cgi module
1 parent c45eb9d commit 1d6ea60

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/saml2/httputil.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import cgi
21
import hashlib
32
import hmac
43
from http.cookies import SimpleCookie
@@ -182,7 +181,10 @@ def extract(environ, empty=False, err=False):
182181
:param empty: Stops on empty fields (default: Fault)
183182
:param err: Stops on errors in fields (default: Fault)
184183
"""
185-
formdata = cgi.parse(environ["wsgi.input"], environ, empty, err)
184+
input_stream = environ["wsgi.input"]
185+
content_length = int(environ.get("CONTENT_LENGTH", 0))
186+
input_data = input_stream.read(content_length).decode('utf-8')
187+
formdata = parse_qs(input_data)
186188
# Remove single entries from lists
187189
for key, value in iter(formdata.items()):
188190
if len(value) == 1:

src/saml2/pack.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
"""
99

1010
import base64
11-
12-
13-
try:
14-
import html
15-
except Exception:
16-
import cgi as html # type: ignore[no-redef]
17-
11+
import html
1812
import logging
13+
1914
from urllib.parse import urlencode
2015
from urllib.parse import urlparse
2116
from xml.etree import ElementTree as ElementTree

0 commit comments

Comments
 (0)