Skip to content

Commit

Permalink
IdentityPython#976 remove import of deprecated cgi module
Browse files Browse the repository at this point in the history
  • Loading branch information
ephes committed Feb 13, 2025
1 parent 0252ec9 commit 175a450
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/saml2/httputil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import cgi
import hashlib
import hmac
from http.cookies import SimpleCookie
Expand Down Expand Up @@ -182,7 +181,10 @@ def extract(environ, empty=False, err=False):
:param empty: Stops on empty fields (default: Fault)
:param err: Stops on errors in fields (default: Fault)
"""
formdata = cgi.parse(environ["wsgi.input"], environ, empty, err)
input_stream = environ["wsgi.input"]
content_length = int(environ.get("CONTENT_LENGTH", 0))
formdata_bytes = input_stream.read(content_length)
formdata = parse_qs(formdata_bytes.decode('utf-8'))
# Remove single entries from lists
for key, value in iter(formdata.items()):
if len(value) == 1:
Expand Down
9 changes: 2 additions & 7 deletions src/saml2/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@
"""

import base64


try:
import html
except Exception:
import cgi as html # type: ignore[no-redef]

import html
import logging

from urllib.parse import urlencode
from urllib.parse import urlparse
from xml.etree import ElementTree as ElementTree
Expand Down

0 comments on commit 175a450

Please sign in to comment.