From 44be256cb06460b1004194a77ef6af5fe64426ff Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 28 Apr 2023 08:32:33 +0200 Subject: [PATCH 1/2] replace deprecated `cgi` module with `EmailMessage.get_content_type` --- src/cryptojwt/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cryptojwt/utils.py b/src/cryptojwt/utils.py index 0d57f803..58727076 100644 --- a/src/cryptojwt/utils.py +++ b/src/cryptojwt/utils.py @@ -1,5 +1,5 @@ import base64 -import cgi +from email.message import EmailMessage import functools import importlib import json @@ -269,5 +269,7 @@ def httpc_params_loader(httpc_params): def check_content_type(content_type, mime_type): """Return True if the content type contains the MIME type""" - mt, _ = cgi.parse_header(content_type) + msg = EmailMessage() + msg['content-type'] = content_type + mt = msg.get_content_type() return mime_type == mt From d3a66f45fdff595e83263af9cd0eddc7b22dbb7f Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 28 Apr 2023 09:41:27 +0200 Subject: [PATCH 2/2] reformat --- src/cryptojwt/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptojwt/utils.py b/src/cryptojwt/utils.py index 58727076..8471840f 100644 --- a/src/cryptojwt/utils.py +++ b/src/cryptojwt/utils.py @@ -1,5 +1,4 @@ import base64 -from email.message import EmailMessage import functools import importlib import json @@ -7,6 +6,7 @@ import struct import warnings from binascii import unhexlify +from email.message import EmailMessage from typing import List from cryptojwt.exception import BadSyntax @@ -270,6 +270,6 @@ def httpc_params_loader(httpc_params): def check_content_type(content_type, mime_type): """Return True if the content type contains the MIME type""" msg = EmailMessage() - msg['content-type'] = content_type + msg["content-type"] = content_type mt = msg.get_content_type() return mime_type == mt