Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
input_data = input_stream.read(content_length).decode('utf-8')
formdata = parse_qs(input_data)
# 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
11 changes: 3 additions & 8 deletions src/saml2/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"""Contains classes and functions that a SAML2.0 Identity provider (IdP)
or attribute authority (AA) may use to conclude its tasks.
"""
import dbm
import importlib
import logging
import shelve
import threading
from dbm import error as DbmError

from saml2 import BINDING_HTTP_REDIRECT
from saml2 import class_name
Expand Down Expand Up @@ -58,13 +58,8 @@
def _shelve_compat(name, *args, **kwargs):
try:
return shelve.open(name, *args, **kwargs)
except dbm.error[0]:
# Python 3 whichdb needs to try .db to determine type
if name.endswith(".db"):
name = name.rsplit(".db", 1)[0]
return shelve.open(name, *args, **kwargs)
else:
raise
except DbmError:
return shelve.open(name.removesuffix(".db"), *args, **kwargs)


class Server(Entity):
Expand Down