Skip to content

Commit 175a450

Browse files
committed
IdentityPython#976 remove import of deprecated cgi module
1 parent 0252ec9 commit 175a450

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/saml2/httputil.py

+4-2
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+
formdata_bytes = input_stream.read(content_length)
187+
formdata = parse_qs(formdata_bytes.decode('utf-8'))
186188
# Remove single entries from lists
187189
for key, value in iter(formdata.items()):
188190
if len(value) == 1:

src/saml2/pack.py

+2-7
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)