Skip to content

Commit

Permalink
Replaces cgi with message according to PEP-594 (#71)
Browse files Browse the repository at this point in the history
Co-authored-by: DigitalTrustCenter <[email protected]>
  • Loading branch information
Sandr0x00 and DigitalTrustCenter authored Jul 10, 2024
1 parent 580299c commit 1e531bc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sectxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import langcodes
import re
import sys
from email.message import Message
import validators
from cgi import parse_header
from collections import defaultdict
from datetime import datetime, timezone
from typing import Optional, Union, List, DefaultDict
Expand Down Expand Up @@ -596,8 +596,10 @@ def _process(self) -> None:
"no_content_type", "HTTP Content-Type header must be sent."
)
else:
media_type, params = parse_header(resp.headers["content-type"])
if media_type.lower() != "text/plain":
m = Message()
m['content-type'] = resp.headers["content-type"]
params = dict(m.get_params())
if "text/plain" not in params:
self._add_error(
"invalid_media",
"Media type in Content-Type header must be "
Expand Down

0 comments on commit 1e531bc

Please sign in to comment.